2

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"]
}]
1

1 Answer 1

4

You can use $elemMatch:

{
   "selector": {
      "games": {
         "$elemMatch": {
            "$eq": "Archery"
         }
      }
   }
}

It will return all objects where games field equals 'Archery'

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.