1
{
  "_id":"12345",
  "model":{
     "T":0,
     "serviceTask":[
        {
          "_id":"6789",
           "obj":{
             "params" :{
                "action": "getEmployeeData",
                "employeeId":"123"
             },
             "url":"www.test.com",
             "var":"test",
           },
           "opp":100
        }
     ]
  }
}

I have similar structured documents in my collection. How do I query the documents that match action value to "getEmployeeData". I tried dot notation with $elemMatchbut couldn't get the results.

1

1 Answer 1

2

Dot notation works fine here, it will return the document if serviceTask contains at least one action set to getEmployeeData

db.collection.find({
    "model.serviceTask.obj.params.action": "getEmployeeData"
})
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.