salix/modules/client/back/models/greuge.js

24 lines
613 B
JavaScript
Raw Permalink Normal View History

const LoopBackContext = require('loopback-context');
2017-12-04 07:17:29 +00:00
module.exports = function(Self) {
require('../methods/greuge/sumAmount')(Self);
2018-01-11 10:22:56 +00:00
Self.observe('before save', function(ctx, next) {
const loopBackContext = LoopBackContext.getCurrentContext();
let userFk = loopBackContext.active.accessToken.userId;
if (ctx.instance)
ctx.instance.userFk = userFk;
else
ctx.data.userFk = userFk;
next();
});
2018-01-11 10:22:56 +00:00
Self.validatesLengthOf('description', {
max: 45,
message: 'Description should have maximum of 45 characters'
2018-01-11 10:22:56 +00:00
});
2017-12-04 07:17:29 +00:00
};