salix/services/loopback/common/helpers.js

25 lines
531 B
JavaScript
Raw Normal View History

exports.UserError = class extends Error {
constructor(message) {
super(message);
this.name = 'UserError';
this.statusCode = 400;
}
};
exports.getFinalState = function(ctx) {
if (ctx.isNewInstance)
return ctx.instance;
if (ctx.currentInstance)
return Object.assign({},
ctx.currentInstance.__data,
ctx.data || ctx.instance
);
return null;
};
exports.isMultiple = function(ctx) {
return !ctx.isNewInstance && !ctx.currentInstance;
};