module.exports = Self => { Self.remoteMethodCtx('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(ctx, addressFk, landed, options) => { const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); let query = ` CALL vn.zone_getAgency(?, ?); SELECT * FROM tmp.zoneGetAgency; DROP TEMPORARY TABLE tmp.zoneGetAgency; `; const result = await Self.rawSql(query, [addressFk, landed], myOptions); return result[1]; }; };