salix/services/client/common/models/receipt.js

14 lines
426 B
JavaScript
Raw Normal View History

2018-10-19 06:40:32 +00:00
module.exports = function(Self) {
require('../methods/receipt/filter')(Self);
2018-10-24 12:10:48 +00:00
Self.observe('before save', async function(ctx) {
if (ctx.isNewInstance) {
let token = ctx.options.accessToken;
let userId = token && token.userId;
let worker = await Self.app.models.Worker.findOne({where: {userFk: userId}});
ctx.instance.workerFk = worker.id;
}
});
2018-10-19 06:40:32 +00:00
};