const LoopBackContext = require('loopback-context'); module.exports = Self => { Self.observe('before save', async function(ctx) { const changes = ctx.data || ctx.instance; const loopBackContext = LoopBackContext.getCurrentContext(); changes.workerFk = loopBackContext.active.accessToken.userId; }); };