couchdbcouchdb-mango

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


Solution

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

    {
       "selector": {
          "linked.type": "XX",
          "linked.code": {
             "$elemMatch": {
                "$eq": "hi"
             }
          }
       }
    }