module.exports = Self => { Self.remoteMethod('landsThatDay', { description: 'Returns a list of agencies that can land a shipment on a day for an address', accepts: [ { arg: 'addressFk', type: 'number', required: true }, { arg: 'landed', type: 'date', required: true } ], returns: { type: 'object', root: true }, http: { path: `/landsThatDay`, verb: 'get' } }); Self.landsThatDay = async(addressFk, landed) => { let query = ` CALL vn.zone_getAgency(?, ?); SELECT * FROM tmp.zoneGetAgency; DROP TEMPORARY TABLE tmp.zoneGetAgency; `; let result = await Self.rawSql(query, [addressFk, landed]); return result[1]; }; };