From 509dab5ce4add2ddae047a298c0535773897c5dc Mon Sep 17 00:00:00 2001 From: nelo Date: Tue, 20 Jun 2017 13:14:20 +0200 Subject: [PATCH] list states --- .../production/common/methods/state/find.js | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/services/production/common/methods/state/find.js b/services/production/common/methods/state/find.js index f40937891c..af8a7c217a 100644 --- a/services/production/common/methods/state/find.js +++ b/services/production/common/methods/state/find.js @@ -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; } }