Guest User

Untitled

a guest
Mar 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. //building ruleConditions
  2. var ruleConditions = {$and: []};
  3.  
  4. var fromConditions = mongoRequestsHelper.getFromConditions(rule.from);
  5. if (fromConditions) ruleConditions.$and.push(fromConditions);
  6.  
  7. //and 4 similar blocks
  8.  
  9. if (mongoRequestsHelper.getFromConditions(rule.moversFilter)) ruleConditions.push(mongoRequestsHelper.getFromConditions(rule.moversFilter))
  10.  
  11. const clauses = [
  12. mongoRequestsHelper.getFromConditions(rule.A),
  13. mongoRequestsHelper.getFromConditions(rule.B),
  14. mongoRequestsHelper.getFromConditions(rule.C),
  15. mongoRequestsHelper.getFromConditions(rule.D),
  16. ......
  17. ];
  18.  
  19. const ruleConditions = {
  20. // filter out non-truthy clauses
  21. $and: clauses.filter(clause => clause)
  22. };
Add Comment
Please, Sign In to add comment