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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -