Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB Shell: find by BinData

I have a document in MongoDB like

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

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

e.g.

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

Not working, any idea?

like image 333
Howard Avatar asked Apr 20 '13 06:04

Howard


1 Answers

Bindata is the base64 representation of a binary string.Must be instantiated.

db.test.find( {"d": new BinData(0,"c9f0f895fb98ab9159f51fd0297e236d") } )
like image 164
user3796198 Avatar answered Oct 02 '22 10:10

user3796198