salix/modules/worker/back/models/worker-observation.js

14 lines
417 B
JavaScript
Raw Normal View History

2023-03-24 11:11:42 +00:00
module.exports = function(Self) {
Self.validate('text', isEnabled, {message: 'Description cannot be blank'});
function isEnabled(err) {
if (!this.text) err();
}
Self.observe('before save', async function(ctx) {
ctx.instance.created = new Date();
let token = ctx.options.accessToken;
let userId = token && token.userId;
ctx.instance.userFk = userId;
});
};