mongoid / origin

A Ruby DSL for building MongoDB queries
http://mongoid.org/en/origin/index.html
MIT License
62 stars 29 forks source link

'where' or 'and'? #69

Closed cpuguy83 closed 11 years ago

cpuguy83 commented 11 years ago

Trying to figure out the difference in behavior between 'where' and 'and'. Obviously I can see in the Mongoid::Criteria how it is built out differently, however I would assume that the definition of 'where' and 'and' would be the same, but obviously are not (and I do get different results when chained with other operations).

I see in the Origin documentation that 'where' only passes a '$where' to mongodb when it's passed a string, and indeed actually using a '$where' in mongodb seems to be very bad unless you absolutely need it.

durran commented 11 years ago

and is for using MongoDB's $and selector, and is also aliased as all_of:

http://mongoid.org/en/origin/docs/selection.html