Reputation: 6029
This Meteor mongo command tries to get the document with the emails[0].address == abc@xyz
but it is failing, Any ideas? thx
db.users.findOne({'emails[0].address':'[email protected]'}).pretty()
"emails" : [
{
"address" : "[email protected]",
Upvotes: 0
Views: 67
Reputation: 2386
that will work only if the string you're looking for is the first element of the array. to search through the whole array, you need $elemMatch. e.g.
db.users.findOne({emails: {
$elemMatch: {address: '[email protected]'}
}})
Upvotes: 0
Reputation: 4326
To make it working please change emails[0].address
to emails.0.address
.
Please see the docs on how to use dot notation in this situation.
Upvotes: 1