MongoDB: find document with composite _id

1.5k views Asked by At

I have documents in my collection with a composite _id like this:

_id:{a:"", b:""}

What that I want is to find the document knowing only the value of the field a. Is there some way to do this?

Thanks!

1

There are 1 answers

0
Rahul Kumar On BEST ANSWER

Sure you can do

db.whatever.find({"_id.a":"valueOfa"});

Or did I not got the question?