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

27 lines
690 B
JavaScript
Raw Normal View History

2018-06-20 09:39:29 +00:00
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;
};
};