refs #5666 perf: loggable to mixin

This commit is contained in:
Javier Segarra 2023-11-13 09:53:35 +01:00
parent 3c5af184bb
commit a102c3f3a9
1 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,12 @@
const LoopBackContext = require('loopback-context');
async function handleObserve(ctx) {
ctx.options.httpCtx = LoopBackContext.getCurrentContext();
}
module.exports = function(Self) {
let Mixin = {
'before save': handleObserve,
'before delete': handleObserve,
};
for (const [listener, handler] of Object.entries(Mixin))
Self.observe(listener, handler);
};