salix/services/client/common/scopes/card.js

39 lines
869 B
JavaScript

module.exports = function(Client) {
// Validations
var card = require('./card.json');
Client.remoteMethod('card', {
description: 'Get client for card call',
accepts: {
arg: 'id',
type: 'number',
required: true,
description: 'Model id',
http: {source: 'path'}
},
returns: {
arg: 'data',
type: 'Client',
root: true
},
http: {
verb: 'get',
path: '/:id/card'
}
});
Client.card = function(id, cb) {
let filter = {
where: {
id: id
},
include: card
};
Client.find(filter, function(err, instances) {
if(!err) {
cb(null, instances[0]);
}
})
};
};