list states

This commit is contained in:
nelo 2017-06-20 13:14:20 +02:00
parent 50e086fbc0
commit 509dab5ce4
1 changed files with 15 additions and 20 deletions

View File

@ -1,30 +1,25 @@
module.exports = function(State) { module.exports = function(State) {
State.remoteMethod('productionStates', { State.list = function(filter, cb) {
description: 'Get production states', State.find(where(filter), function(err, states) {
returns: {
arg: 'states',
type: 'object'
},
http: {
verb: 'get',
path: '/productionStates'
}
});
State.productionStates = function(cb) {
State.find(where(), function(err, states) {
if(!err){ if(!err){
cb(null, states); cb(null, states);
} }
}); });
}; };
function where() { function where(filter) {
return {
where: { if(!filter)
"order": {gt: 0} return {
}, where: {
order: "order, name" "order": {gt: 0 }
},
order: "order, name"
}
else{
filter.where.order = {gt: 0 };
filter.order = "order, name";
return filter;
} }
} }