@@ -18,6 +18,7 @@ export class api_credentials {
1818 constructor ( public config : Iapi_get_jwt ) {
1919 RED . nodes . createNode ( this , config ) ;
2020 this . node = this ;
21+ this . node . status ( { } ) ;
2122 if ( this . node . credentials && this . node . credentials . hasOwnProperty ( "username" ) ) {
2223 this . username = this . node . credentials . username ;
2324 }
@@ -35,6 +36,7 @@ export class api_get_jwt {
3536 constructor ( public config : Iapi_get_jwt ) {
3637 RED . nodes . createNode ( this , config ) ;
3738 this . node = this ;
39+ this . node . status ( { } ) ;
3840 this . node . on ( "input" , this . oninput ) ;
3941 this . node . on ( "close" , this . onclose ) ;
4042 }
@@ -92,6 +94,7 @@ export class api_get {
9294 constructor ( public config : Iapi_get ) {
9395 RED . nodes . createNode ( this , config ) ;
9496 this . node = this ;
97+ this . node . status ( { } ) ;
9598 this . node . on ( "input" , this . oninput ) ;
9699 this . node . on ( "close" , this . onclose ) ;
97100 }
@@ -152,6 +155,7 @@ export class api_add {
152155 constructor ( public config : Iapi_add ) {
153156 RED . nodes . createNode ( this , config ) ;
154157 this . node = this ;
158+ this . node . status ( { } ) ;
155159 this . node . on ( "input" , this . oninput ) ;
156160 this . node . on ( "close" , this . onclose ) ;
157161 }
@@ -223,6 +227,7 @@ export class api_update {
223227 constructor ( public config : Iapi_update ) {
224228 RED . nodes . createNode ( this , config ) ;
225229 this . node = this ;
230+ this . node . status ( { } ) ;
226231 this . node . on ( "input" , this . oninput ) ;
227232 this . node . on ( "close" , this . onclose ) ;
228233 }
@@ -255,7 +260,7 @@ export class api_update {
255260 if ( ! NoderedUtil . IsNullEmpty ( this . config . entitytype ) ) {
256261 element . _type = this . config . entitytype ;
257262 }
258- Promises . push ( NoderedUtil . UpdateOne ( this . config . collection , element , this . config . writeconcern , this . config . journal , msg . jwt ) ) ;
263+ Promises . push ( NoderedUtil . UpdateOne ( this . config . collection , null , element , this . config . writeconcern , this . config . journal , msg . jwt ) ) ;
259264 }
260265 data = await Promise . all ( Promises . map ( p => p . catch ( e => e ) ) ) ;
261266
@@ -294,6 +299,7 @@ export class api_addorupdate {
294299 constructor ( public config : Iapi_addorupdate ) {
295300 RED . nodes . createNode ( this , config ) ;
296301 this . node = this ;
302+ this . node . status ( { } ) ;
297303 this . node . on ( "input" , this . oninput ) ;
298304 this . node . on ( "close" , this . onclose ) ;
299305 }
@@ -364,6 +370,7 @@ export class api_delete {
364370 constructor ( public config : Iapi_delete ) {
365371 RED . nodes . createNode ( this , config ) ;
366372 this . node = this ;
373+ this . node . status ( { } ) ;
367374 this . node . on ( "input" , this . oninput ) ;
368375 this . node . on ( "close" , this . onclose ) ;
369376 }
@@ -428,6 +435,7 @@ export class api_map_reduce {
428435 constructor ( public config : Iapi_map_reduce ) {
429436 RED . nodes . createNode ( this , config ) ;
430437 this . node = this ;
438+ this . node . status ( { } ) ;
431439 this . node . on ( "input" , this . oninput ) ;
432440 this . node . on ( "close" , this . onclose ) ;
433441 }
@@ -491,6 +499,7 @@ export class api_updatedocument {
491499 constructor ( public config : Iapi_updatedocument ) {
492500 RED . nodes . createNode ( this , config ) ;
493501 this . node = this ;
502+ this . node . status ( { } ) ;
494503 this . node . on ( "input" , this . oninput ) ;
495504 this . node . on ( "close" , this . onclose ) ;
496505 }
@@ -518,8 +527,13 @@ export class api_updatedocument {
518527 }
519528
520529 this . node . status ( { fill : "blue" , shape : "dot" , text : "Running Update Document" } ) ;
521- var result = await NoderedUtil . UpdateMany ( this . config . collection , this . config . query , this . config . updatedocument , this . config . writeconcern , this . config . journal , msg . jwt ) ;
522- msg . payload = result ;
530+ if ( this . config . action === "updateOne" ) {
531+ var result = await NoderedUtil . UpdateOne ( this . config . collection , this . config . query , this . config . updatedocument , this . config . writeconcern , this . config . journal , msg . jwt ) ;
532+ msg . payload = result ;
533+ } else {
534+ var result = await NoderedUtil . UpdateMany ( this . config . collection , this . config . query , this . config . updatedocument , this . config . writeconcern , this . config . journal , msg . jwt ) ;
535+ msg . payload = result ;
536+ }
523537 this . node . send ( msg ) ;
524538 this . node . status ( { } ) ;
525539 } catch ( error ) {
0 commit comments