node.js - after save update attrubutes infinite loop -
in loopback application, using mongodb backend
consider have 2 collections a,b. relation a hasone b
. in aftersave
hook of model have implemented
if(isnewinstance) { // when creating have compute data // , create document in b , have update _id of b // updating calling: ctx.instances.updateattributes();// once again call //after save hook , isnewinstance == false, // go in else condition also. } else { // when updating have compute data , create document in b // , have update _id of b }
**summary**
: when creating new instance of triggering twice because of updateattributes, how can restrict when editing instance should call not on calling updateattributes.. please share ideas. in advance..
if(isnewinstance) { if(ctx.instance.needtoupdate){ process.nexttick(() => { ctx.instance.updateattributes(); }); } } else { }
Comments
Post a Comment