Answer the question
In order to leave comments, you need to log in
What query in mongodb can get objects containing an object with a field equal to "x"?
For example, we have the following objects in the collection:
"id" : 1,
"visits" : [
{
"userId" : "1",
"date" : 1390482788
},
{
"userId" : "2",
"date" : 1386912055
},
Answer the question
In order to leave comments, you need to log in
db.collection.find( {visits: {userId: 1}} );
or
db.collection.find( {"visits.userId": 1} );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question