salix/modules/item/back/methods/item-barcode/toItem.js

29 lines
700 B
JavaScript
Raw Normal View History

2019-02-22 07:32:18 +00:00
module.exports = Self => {
Self.remoteMethod('toItem', {
description: 'Returns last entries',
accessType: 'READ',
accepts: [{
arg: 'barcode',
type: 'Number',
required: true,
description: 'barcode'
}],
returns: {
type: 'Number',
root: true
},
http: {
path: `/:barcode/toItem`,
verb: 'GET'
}
});
Self.toItem = async barcode => {
let query = `SELECT vn.barcodeToItem(?)`;
let [item] = await Self.rawSql(query, [barcode]);
if (item)
item = Object.values(item);
return item[0];
};
};