Reputation: 461
I have a mongo document structure like this:
{
"competition_id" : 421,
"matches" :
[
"m_id" : 1234,
"players":
[
{
"id" : 52165267,
"name" : "...",
"surname" : "...",
..
}
],
"date" : 2012-10-12,
...
]
}
I want to be able to find (return) all documents that (for a given $player_id), the player doesn`t exists in "matches.players.id"s array. I tried the '$nin' operator but with no success.
Thanks
Upvotes: 0
Views: 82
Reputation: 11767
Firstly in 'matches' replace your '[' with '{'
I tried your sample document and the below query works fine for me:
db.collection_name.find( {"matches.players.id":{'$nin':[5]}} )
Upvotes: 1