Make $elemMatch support single object

XMLWordPrintableJSON

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

      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
              Reporter:
              Zefei Xuan
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: