salix/modules/item/back/methods/item/getLastEntries.js

29 lines
723 B
JavaScript

module.exports = Self => {
Self.remoteMethod('getLastEntries', {
description: 'Returns last entries',
accessType: 'READ',
accepts: [{
arg: 'filter',
type: 'object',
required: true,
description: 'itemFk, id'
}],
returns: {
type: 'Array',
root: true
},
http: {
path: `/getLastEntries`,
verb: 'GET'
}
});
Self.getLastEntries = async filter => {
let where = filter.where;
let query = `CALL vn.itemLastEntries(?, ?)`;
let [lastEntries] = await Self.rawSql(query, [where.itemFk, where.date]);
return lastEntries;
};
};