简体   繁体   English

MongoDB-mongohub gui-按_id objectid类型进行查询

[英]MongoDB - mongohub gui - queries by _id objectid type

I am using MongoHub GUI for MongoDB: http://mongohub.todayclose.com/ 我正在为MongoDB使用MongoHub GUI: http ://mongohub.todayclose.com/

I would like to be able to query by ObjectId as this is what MongoHub is returing for _id. 我希望能够通过ObjectId进行查询,因为这是MongoHub为_id重现的内容。 How to do this, something like {"_id":"4d1b4687a6d5437619000000"} is not working?? 如何执行此操作,例如{“ _id”:“ 4d1b4687a6d5437619000000”}无效?

cheers, /Marcin 干杯,/ Marcin

{"_id": { $oid: "4d1b4687a6d5437619000000"}} definitely should work. {"_id": { $oid: "4d1b4687a6d5437619000000"}}绝对可以正常工作。 Java MongoDB driver implicitly creates ObjectId object in the object has '$oid' property. Java MongoDB驱动程序在具有'$oid'属性的对象中隐式创建ObjectId对象。 Also all the same is for date using '$date' property. 使用'$ date'属性的日期也相同。

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). 在查询中提供函数的情况下,MongoHub似乎已损坏( ObjectId ,正如galimy正确建议的那样)。 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. 如果按照galimy的建议输入查询,然后将MongoHub 表示将要执行的完整查询(在“查询”文本输入上方显示为灰色)复制并粘贴到连接的mongo CLI控制台中,即可正常工作。

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. 我建议学习使用mongo控制台-我在玩MongoHub的5分钟内发现了两个错误,而且无论如何,当您输入JSON进行查询时,GUI都对您无济于事。

OK, it has been fixed in recent MongoHub release. 好的,它已在最近的MongoHub版本中修复。 Cheers 干杯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM