Advertisement
benshepherd

search.js example

Mar 20th, 2016
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. var search = new SearchBuilder('Peoples');
  3.  
  4. // older than 21
  5. search.where('age', 21).greaterThan();
  6.  
  7. // all genders that are not male
  8. search.where('gender', 'male').notEquals();
  9.  
  10. // find all people with j at the beggining of their name
  11. search.where('name', 'j').appearsFirst().orWhere();
  12.  
  13. // Add a grouped where
  14. var group = search.whereGroup();
  15. group.where('age', '25').notEquals();
  16. group.where('age', '30').notEquals();
  17.  
  18. search.submit(function(peoples) {
  19.         // do stuff with peoples   
  20. });
  21.  
  22. // THE OUTPUT
  23. // select * from peoples where `age` > 21 and `gender` != 'male' or `name` LIKE 'j%' and (`age` != 25 and `age` != 30);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement