removed eslint errors

This commit is contained in:
Daniel Herrero 2017-11-09 08:59:40 +01:00
parent d2491bfbf4
commit 3d33c21cc8
1 changed files with 17 additions and 13 deletions

View File

@ -45,18 +45,20 @@ module.exports = function(Self) {
});
this.list = function(ctx, clientFilter, cb) {
var clientFields = (clientFilter && clientFilter.fields) ? clientFilter.fields : [];
var serverFields = (serverFilter && serverFilter.fields) ? serverFilter.fields : [];
var fields = clientFields.filter(itemC => {
let clientFields = (clientFilter && clientFilter.fields) ? clientFilter.fields : [];
let serverFields = (serverFilter && serverFilter.fields) ? serverFilter.fields : [];
let fields = clientFields.filter(itemC => {
return serverFields.some(itemS => itemS === itemC);
});
let and = [];
let order;
let limit;
let filter = {order: order, limit: limit};
var and = [];
(clientFilter && clientFilter.where) && and.push(clientFilter.where);
(serverFilter && serverFilter.where) && and.push(serverFilter.where);
var order;
var limit;
if (clientFilter && clientFilter.where)
and.push(clientFilter.where);
if (serverFilter && serverFilter.where)
and.push(serverFilter.where);
if (clientFilter && clientFilter.order)
order = clientFilter.order;
@ -68,12 +70,14 @@ module.exports = function(Self) {
else if (clientFilter && clientFilter.limit)
limit = clientFilter.limit;
var filter = {order: order, limit: limit};
filter.where = (and.length > 0) && {and: and};
filter.fields = fields;
this.find(filter, function(err, states) {
(err) ? cb(err, null) : cb(null, states);
if (err)
cb(err, null);
else
cb(null, states);
});
};
};
@ -198,8 +202,8 @@ function removeEmpty(o) {
let array = [];
for (let item of o) {
let i = removeEmpty(item);
if (!isEmpty(item))
array.push(item);
if (!isEmpty(i))
array.push(i);
}
if (array.length > 0)
return array;