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

Add an operator that matches an entire document

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Backlog
    • Minor - P4
    • Resolution: Unresolved
    • None
    • None
    • Querying
    • None
    • Query Optimization

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              backlog-query-optimization Backlog - Query Optimization
              richard.kreuter Richard Kreuter (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated: