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

Make $elemMatch support single object

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.1.0
    • Component/s: Querying
    • Labels:

      Currently $elemMatch only supports array values, so queries such as {foo: {$elemMatch:

      {a:1, b:2}

      }} will match {foo:[

      {a:1, b:2, c:3}

      ]}, but not {foo: {a:1, b:2, c:3}}. I know this can be easily done by query

      {'foo.a':1, 'foo.b':2}

      , but this behavior is inconsistent with other query operations; e.g.

      {a:1}

      will match both

      {a:[1]}

      and

      {a:1}

      .

      I'm currently writing a DSL for mongo, and I find it hard to explain this inconsistency to users. But I don't know if changing this will affect query optimizer.

            Assignee:
            Unassigned Unassigned
            Reporter:
            zefei Zefei Xuan
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: