MongoDB Compass filter (query)
Asked Answered
S

1

20

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.

Shorts answered 15/7, 2019 at 13:0 Comment(0)
K
38

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

Karat answered 15/7, 2019 at 13:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.