Quantcast
Channel: mongodb $elemMatch - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Kevin Meredith for mongodb $elemMatch

$
0
0

How about this:

db.items.find({x : { $all: [  {$elemMatch: {a: 1, b: 2}},   {$elemMatch: {a: 3, b: 4}},   {$elemMatch: {a: 5, b: 6}}    ]}}

Check out the Mongo docs.

Also, note the docs warning:

In the current release, queries that use the $all operator must scan all the documents that match the first element in the query array. As a result, even with an index to support the query, the operation may be long running, particularly when the first element in the array is not very selective.


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>