Aman
Aman

Reputation: 3261

CouchDB query list not giving any result

I am trying to query in couchDB to filter with code ='hi'

{
id:1,
linked": {
  "type": "XX",
  "code": [
   "hi",
   "hello"
  ]
 }

This is how I am trying:

{
   "selector": {
      "linked": {
         "type": "xx",
         "$elemMatch": {
            "code": "hi"
         }
      }
   }
}

I am not getting output.Can anybody help

Upvotes: 0

Views: 86

Answers (1)

Glynn Bird
Glynn Bird

Reputation: 5637

If I understand the intention of your query correctly, I think you mean:

{
   "selector": {
      "linked.type": "XX",
      "linked.code": {
         "$elemMatch": {
            "$eq": "hi"
         }
      }
   }
}
  • to access sub-objects of your document use "dot notation" e.g. linked.type
  • the equality operator is case sensitive. "XX" not "xx"
  • the $elemMatch operator was specified incorrectly. See the docs here

Upvotes: 3

Related Questions