So, MongoDB defaults to “AND” when finding records. For example:
db.users.find({age: {'$gte': 30}, {'$lte': 40}});
The above query finds users >= 30 AND <= 40 years old.
How would I find users <= 30 OR >= 40 years old?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There will be an or operator in the near future. The nightly Mongodb build has already an $or. You can also use $where and use JavaScript to express the or.
See http://groups.google.com/group/mongodb-user/browse_thread/thread/a9a4d8b863d84601