MongoDB Compass filter (query)

Pradeep Singh picture Pradeep Singh · Jul 15, 2019 · Viewed 26.8k times · Source

enter image description here

In mongoDB compass I am getting no result with the below filters. Not sure what I am doing wrong.

  1. {user: {uid: 'ttorone'}}
  2. {user: {_id: ObjectId("5b9fc9567a1f050026a8bbda")}}

What I want is to filter out this document (where user-> uid is 'ttorone'). User is also an object here.

Answer

user11380812 picture user11380812 · Jul 15, 2019

Try like this {"user.uid" : "ttorone"}

For example if I would like to get all movies documents that have "imbd.id" equals to 1, I put the following filter in the compass, see the image below. Your situation is similar. You are searching for property value in the embedded object.

enter image description here