Reputation: 95
I need to get the documents where exists Archery
in the array list of games
. How can i do with CouchDB selector?
[{
"name": "John",
"games": ["Archery", "Board sports"]
},
{
"name": "Sara",
"games": ["Fishing", "Archery"]
},
{
"name": "Tara",
"games": ["Decathlon"]
}]
Upvotes: 2
Views: 1232
Reputation: 1377
You can use $elemMatch
:
{
"selector": {
"games": {
"$elemMatch": {
"$eq": "Archery"
}
}
}
}
It will return all objects where games
field equals 'Archery'
Upvotes: 3