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 => {
|
2018-07-16 07:28:32 +00:00
|
|
|
let where = filter.where;
|
2018-06-20 09:39:29 +00:00
|
|
|
let query = `CALL vn.itemLastEntries(?, ?)`;
|
2018-07-16 07:28:32 +00:00
|
|
|
let [lastEntries] = await Self.rawSql(query, [where.itemFk, where.date]);
|
2018-06-20 09:39:29 +00:00
|
|
|
return lastEntries;
|
|
|
|
};
|
|
|
|
};
|