module.exports = function(Self) { Self.remoteMethod('card', { description: 'Get client basic data', accepts: { arg: 'id', type: 'number', required: true, description: 'The client id', http: {source: 'path'} }, returns: { type: 'Object', root: true }, http: { verb: 'GET', path: '/:id/card' } }); Self.card = async function(id) { return await Self.findOne({ where: { id: id }, include: [ { relation: 'salesPerson', scope: { fields: ['id', 'firstName', 'name'] } }, { relation: 'contactChannel', scope: { fields: ['id', 'name'] } }, { relation: 'province', scope: { fields: ['id', 'name'] } }, { relation: 'country', scope: { fields: ['id', 'country'] } }, { relation: 'payMethod', scope: { fields: ['id', 'name'] } }, { relation: 'account', scope: { fields: ['id', 'name', 'active'] } } ] }); }; };