salix/services/loopback/common/methods/item/getLastEntries.js

27 lines
690 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 query = `CALL vn.itemLastEntries(?, ?)`;
let [lastEntries] = await Self.rawSql(query, [filter.itemFk, filter.date]);
return lastEntries;
};
};