before find loopback code example
Example 1: loopback before save
module.exports = function (model) {
model.observe('before save', async function(ctx, next) {
});
};
Example 2: hook access loopback
Model.observe('access', function logQuery(ctx, next) {
console.log('Accessing %s matching %s', ctx.Model.modelName, ctx.query.where);
next();
});
Example 3: loopback get relationship in before save
// it is not availabe in the "before save" event.
// you must do a Model.find()