转自:https://www.2cto.com/database/201704/633262.html
mongodb命令行_id查询方法
- 直接用ObjectId()
db.getCollection(‘imangtextcol’).find({“_id”:ObjectId(“58f9b20b8c8858538af69409”)})
java中_id查询方法
- new ObjectId(id)
BasicDBObject queryObject = new BasicDBObject(“_id”,new ObjectId(id));