开发者

MongoDB - mongohub gui - queries by _id objectid type

I am using MongoHub GUI for MongoDB: http://mongohub.todayclose.com/

I would like to be able to query by ObjectId as thi开发者_高级运维s is what MongoHub is returing for _id. How to do this, something like {"_id":"4d1b4687a6d5437619000000"} is not working??

cheers, /Marcin


try following code:

{"_id": ObjectId("4d1b4687a6d5437619000000")}

check this for more details


It looks as if MongoHub is broken in the case of supplying a function in a query (ObjectId, as galimy rightly suggested). If you enter the query as galimy suggested, then copy and paste the full query that MongoHub says it's going to execute (grayed out above the Query text input) into a connected mongo CLI console, it works fine.

I would recommend learning to use the mongo console -- I've found two bugs in 5 minutes of playing with MongoHub, and when you're typing in JSON for your queries anyway the GUI is doing very little for you.


OK, it has been fixed in recent MongoHub release. Cheers


{"_id": { $oid: "4d1b4687a6d5437619000000"}} definitely should work. Java MongoDB driver implicitly creates ObjectId object in the object has '$oid' property. Also all the same is for date using '$date' property.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜