module.exports = Self => { Self.remoteMethod('isEditable', { description: 'Check if an order is editable', accessType: 'READ', accepts: [{ arg: 'orderId', type: 'number', required: true, description: 'orderId', http: {source: 'path'} }], returns: { type: 'boolean', root: true }, http: { path: `/:orderId/isEditable`, verb: 'get' } }); Self.isEditable = async orderId => { let exists = await Self.app.models.Order.findOne({where: {id: orderId}, fields: ['isConfirmed']}); if (!exists || exists.isConfirmed === 1) return false; return true; }; };