MONGODB - 用JAVA找到“_id”

时间:2017-11-22 18:31:04

标签: java mongodb find mongodb-query mongodb-java

我正在尝试执行此查询:

db.indexInverse.find({_id:ObjectId("5a153409b9c52933c8aab068")}).pretty()

使用Java ...

实际上我尝试了很多东西......但是找不到我的文件......

Document vraiDoc = collectionIndexInverse.find(Filters.eq("_id", new ObjectId("\"" + idDoc + "\""))).first();

OR

Bson query = (Bson) new BsonString("{ _id:ObjectId(\"" + idDoc + "\")}");
Document vraiDoc = collectionIndexInverse.find(query).first();

OR

Bson query = (Bson) new BsonString("{ _id:ObjectId(idDoc)}");
Document vraiDoc = collectionIndexInverse.find(query).first();

0 个答案:

没有答案