list states
This commit is contained in:
parent
50e086fbc0
commit
509dab5ce4
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue