Yes it will
Now it makes more sense than
So the answer should make more sense too.
Documents in collection
{ "_id" : 0 ,
"entries" : [
{ "name" : 2 , "age" : 3 } ,
{ "name" : 4 , "age" : 5 } ,
{ "name" : 6 , "age" : 7 }
]
}
{ "_id" : 1 ,
"entries" : [
{ "name" : 2 , "age" : 5 } ,
{ "name" : 4 , "age" : 3 }
]
}
The following query will find all documents.
{ "entries.name" : 2 , "entries.age" : 3 }
However this one, will only find _id:0 because it is specified in the query.
{ "_id" : 0 , "entries.name" : 2 , "entries.age" : 3 }
The next one will only find _id:0. It does not find _id:1 because name:2 and age:3 is not both true for the same element.
{ "entries" : { "$elemMatch" : { "name" : 2 , "age" : 3 } }
In all cases, all elements of entries are sent in the result. To restrict the element of entries that are sent you need to use
or
I think both only project the first element that matches. The only way I know to project more element will be to use $filter within an aggregation pipeline.