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) {
State.remoteMethod('productionStates', {
description: 'Get production states',
returns: {
arg: 'states',
type: 'object'
},
http: {
verb: 'get',
path: '/productionStates'
}
});
State.productionStates = function(cb) {
State.find(where(), function(err, states) {
State.list = function(filter, cb) {
State.find(where(filter), function(err, states) {
if(!err){
cb(null, states);
}
});
};
function where() {
return {
where: {
"order": {gt: 0}
},
order: "order, name"
function where(filter) {
if(!filter)
return {
where: {
"order": {gt: 0 }
},
order: "order, name"
}
else{
filter.where.order = {gt: 0 };
filter.order = "order, name";
return filter;
}
}