benshepherd icon

search.js example

benshepherd | PRO | 03/20/16 08:55:10 PM UTC | 0 ⭐ | 356 👁️ | Never ⏰ | []
JavaScript |

630 B

|

None

|

0 👍

/

0 👎

 
var search = new SearchBuilder('Peoples');
 
// older than 21
search.where('age', 21).greaterThan();
 
// all genders that are not male
search.where('gender', 'male').notEquals();
 
// find all people with j at the beggining of their name
search.where('name', 'j').appearsFirst().orWhere();
 
// Add a grouped where
var group = search.whereGroup();
group.where('age', '25').notEquals();
group.where('age', '30').notEquals();
 
search.submit(function(peoples) {
        // do stuff with peoples    
});
 
// THE OUTPUT
// select * from peoples where `age` > 21 and `gender` != 'male' or `name` LIKE 'j%' and (`age` != 25 and `age` != 30);

Comments