loopback
loopback copied to clipboard
Cannot pass data between before save and after save
module.exports = function(Home) {
Home.observe('before save', function (ctx, next) { console.log("before save") console.log(ctx.data.id);
Home.findById(ctx.data.id, function(err, instance){
console.log(instance)
ctx.hookState = instance;
next();
})
});
Home.observe('after save', function (ctx, next) { console.log("after save") console.log(ctx.hookState) next(); }); };
My goal is to log what changes where made to the model in the after save method.
Got it. http://stackoverflow.com/questions/38638637/pass-context-in-persist-to-after-save/38660028#38660028