Skip to content

Commit d0e31b8

Browse files
committed
Don't stop on null/0 data
1 parent 28f8107 commit d0e31b8

1 file changed

Lines changed: 24 additions & 23 deletions

File tree

OpenFlowNodeRED/src/nodered/nodes/api_nodes.ts

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,10 @@ export class api_add {
250250

251251
let data: any[] = [];
252252
const _data = NoderedUtil.FetchFromObject(msg, this.config.inputfield);
253-
if (NoderedUtil.IsNullUndefinded(_data)) { return NoderedUtil.HandleError(this, "Input data is null"); }
254-
if (!Array.isArray(_data)) { data.push(_data); } else { data = _data; }
255-
256-
if (data.length === 0) { this.node.warn("input array is empty"); return; }
253+
if (!NoderedUtil.IsNullUndefinded(_data)) {
254+
if (!Array.isArray(_data)) { data.push(_data); } else { data = _data; }
255+
if (data.length === 0) { this.node.warn("input array is empty"); return; }
256+
} else { this.node.warn("Input data is null"); }
257257

258258
this.node.status({ fill: "blue", shape: "dot", text: "Inserting items" });
259259
const Promises: Promise<any>[] = [];
@@ -325,10 +325,10 @@ export class api_update {
325325

326326
let data: any[] = [];
327327
const _data = NoderedUtil.FetchFromObject(msg, this.config.inputfield);
328-
if (NoderedUtil.IsNullUndefinded(_data)) { return NoderedUtil.HandleError(this, "Input data is null"); }
329-
if (!Array.isArray(_data)) { data.push(_data); } else { data = _data; }
330-
331-
if (data.length === 0) { this.node.warn("input array is empty"); return; }
328+
if (!NoderedUtil.IsNullUndefinded(_data)) {
329+
if (!Array.isArray(_data)) { data.push(_data); } else { data = _data; }
330+
if (data.length === 0) { this.node.warn("input array is empty"); return; }
331+
} else { this.node.warn("Input data is null"); }
332332

333333
// this.node.status({ fill: "blue", shape: "dot", text: "Inserting items" });
334334
// const Promises: Promise<any>[] = [];
@@ -412,13 +412,12 @@ export class api_addorupdate {
412412
if ((this.config.writeconcern as any) === undefined || (this.config.writeconcern as any) === null) this.config.writeconcern = 0;
413413
if ((this.config.journal as any) === undefined || (this.config.journal as any) === null) this.config.journal = false;
414414

415-
416415
let data: any[] = [];
417416
const _data = NoderedUtil.FetchFromObject(msg, this.config.inputfield);
418-
if (NoderedUtil.IsNullUndefinded(_data)) { return NoderedUtil.HandleError(this, "Input data is null"); }
419-
if (!Array.isArray(_data)) { data.push(_data); } else { data = _data; }
420-
421-
if (data.length === 0) { this.node.warn("input array is empty"); return; }
417+
if (!NoderedUtil.IsNullUndefinded(_data)) {
418+
if (!Array.isArray(_data)) { data.push(_data); } else { data = _data; }
419+
if (data.length === 0) { this.node.warn("input array is empty"); return; }
420+
} else { this.node.warn("Input data is null"); }
422421

423422
this.node.status({ fill: "blue", shape: "dot", text: "processing ..." });
424423
let Promises: Promise<any>[] = [];
@@ -482,10 +481,10 @@ export class api_delete {
482481

483482
let data: any[] = [];
484483
const _data = NoderedUtil.FetchFromObject(msg, this.config.inputfield);
485-
if (NoderedUtil.IsNullUndefinded(_data)) { return NoderedUtil.HandleError(this, "Input data is null"); }
486-
if (!Array.isArray(_data)) { data.push(_data); } else { data = _data; }
487-
488-
if (data.length === 0) { this.node.warn("input array is empty"); return; }
484+
if (!NoderedUtil.IsNullUndefinded(_data)) {
485+
if (!Array.isArray(_data)) { data.push(_data); } else { data = _data; }
486+
if (data.length === 0) { this.node.warn("input array is empty"); return; }
487+
} else { this.node.warn("Input data is null"); }
489488

490489
this.node.status({ fill: "blue", shape: "dot", text: "processing ..." });
491490
let Promises: Promise<any>[] = [];
@@ -798,9 +797,10 @@ export class grant_permission {
798797

799798
let data: any[] = [];
800799
const _data = NoderedUtil.FetchFromObject(msg, this.config.entities);
801-
if (NoderedUtil.IsNullUndefinded(_data)) { return NoderedUtil.HandleError(this, "Input data is null"); }
802-
if (!Array.isArray(_data)) { data.push(_data); } else { data = _data; }
803-
if (data.length === 0) { this.node.warn("input array is empty"); return; }
800+
if (!NoderedUtil.IsNullUndefinded(_data)) {
801+
if (!Array.isArray(_data)) { data.push(_data); } else { data = _data; }
802+
if (data.length === 0) { this.node.warn("input array is empty"); return; }
803+
} else { this.node.warn("Input data is null"); }
804804

805805
this.node.status({ fill: "blue", shape: "dot", text: "processing ..." });
806806
for (let i = 0; i < data.length; i++) {
@@ -864,9 +864,10 @@ export class revoke_permission {
864864

865865
let data: any[] = [];
866866
const _data = NoderedUtil.FetchFromObject(msg, this.config.entities);
867-
if (NoderedUtil.IsNullUndefinded(_data)) { return NoderedUtil.HandleError(this, "Input data is null"); }
868-
if (!Array.isArray(_data)) { data.push(_data); } else { data = _data; }
869-
if (data.length === 0) { this.node.warn("input array is empty"); return; }
867+
if (!NoderedUtil.IsNullUndefinded(_data)) {
868+
if (!Array.isArray(_data)) { data.push(_data); } else { data = _data; }
869+
if (data.length === 0) { this.node.warn("input array is empty"); return; }
870+
} else { this.node.warn("Input data is null"); }
870871

871872
for (let i = 0; i < data.length; i++) {
872873

0 commit comments

Comments
 (0)