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]; }; };