MongoDB Shell: Find by BinData

I have a document in MongoDB, for example

{ "_id" : ObjectId("51723a2f2b9b90e9eb190c45"), "d" : BinData(0,"c9f0f895fb98ab9159f51fd0297e236d") } 

The "d" field is indexed, but how can I find its value in the mongo shell?

eg.

 db.test.find( {"d": BinData(0,"c9f0f895fb98ab9159f51fd0297e236d") } ) 

Doesn't work, any idea?

+4
source share
1 answer

Bindata is a base64 representation of a binary string. You must create an instance.

 db.test.find( {"d": new BinData(0,"c9f0f895fb98ab9159f51fd0297e236d") } ) 
+2
source

All Articles