14 lines
417 B
JavaScript
14 lines
417 B
JavaScript
|
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;
|
||
|
});
|
||
|
};
|