davidgtonge / backbone_query

A lightweight query api for Backbone Collections
MIT License
378 stars 29 forks source link

two or more checks on same argument #13

Closed 3-16 closed 11 years ago

3-16 commented 11 years ago

I am building my querys dynamically. Therefore It would be great if backbone_query had the ability to check two or more times on the same argument. Meaning that these are the same:

MyCollection.query({ likes: {$gte:5}, likes: {$lte:15} });

MyCollection.query({ likes: {$between:[5,15} });

I can´t get it to work. This does not work either:

MyCollection.query({
  $and:{
    likes: {$gte: 5 }, 
    likes: {$lte: 15 }
}});
davidgtonge commented 11 years ago

Hi, you can use an array rather than an object to get this behaviour. I don't have time to test the code, but you should be able to do something like this:

MyCollection.query([
{ likes: {$gte:5} }, 
{ likes: {$lte:15} }
]);
3-16 commented 11 years ago

Thank you that works great!