module.exports = Self => { Self.remoteMethod('getTotalVolume', { description: 'Gets the total volume for an order', accessType: 'READ', accepts: [{ arg: 'id', type: 'number', required: true, description: 'ticket id', http: {source: 'path'} }], returns: { type: 'number', root: true }, http: { path: `/:id/getTotalVolume`, verb: 'GET' } }); Self.getTotalVolume = async orderFk => { let query = `SELECT vn.orderTotalVolume(?) totalVolume, vn.orderTotalVolumeBoxes(?) totalBoxes`; let [res] = await Self.rawSql(query, [orderFk, orderFk]); return res; }; };