For example, if we were keeping inventory and we had both There are ways to do this (see $where Queries), but you will usually get better performance by restructuring your document slightly, such that a “normal” query will suffice.
In this example, we could instead use the keys " field was greater than or equal to 18 AND less than or equal to 30.
These types of range queries are often useful for dates.
For example, to find people who registered before January 1, 2007, we can do this: An exact match on a date is less useful, since dates are only stored with millisecond precision.
There are a couple of ways to get the expected behavior.
Often you want a whole day, week, or month, making a range query necessary.
To query for documents where a key’s value is not equal to a certain value, you must use another conditional operator, is very flexible and allows you to specify criteria of different types as well as values.
If there were fewer than 33 elements in the array, it would return as many as possible.
Unless otherwise specified, all keys in a document are returned when Neither 5 nor 25 is between 10 and 20, but the document is returned because 25 matches the first clause (it is greater than 10) and 5 matches the second clause (it is less than 20).
This type of query is also order-sensitive: would not be a match.