Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-12199

Add an operator that matches an entire document

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 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.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            richard.kreuter Richard Kreuter (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: