-
Type: New Feature
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Querying
-
None
-
Query Optimization
Problem: it's occasionally desirable to be able to specify query that matches a whole document, but the query language doesn't support it (anyway, I can't think of one).
Proposal: add a query operator that matches if and only if a document has all the fields and no extra ones. For example, it might look like this:
db.foo.find({ "$whole" : { "_id" : 123 , "a" : "hello" , "b" : "world" } });
This would match only documents having the fields "_id", "a", and "b", but no other fields; and presumably it would match only if the document had those three fields in that order.
Note that this would make certain updates easier to express, e.g., for the update-if-current idiom.
- is related to
-
SERVER-30196 $size for objects (implementing update-if-current/atomics)
- Closed