简体   繁体   English

Mongodb Java 3.0驱动程序误解

[英]Mongodb java 3.0 driver misunderstanding

I am using the java 3.0 Mongodb driver, and trying to use distinct. 我正在使用Java 3.0 Mongodb驱动程序,并尝试使用与众不同的驱动程序。

With the deprecated DBCollection I can do the following: 使用已弃用的DBCollection,我可以执行以下操作:

collection.distinct("tokens.account_id", new BasicDBObject("_id",new ObjectId(objectiId)))

However, I can't seem to accomplish the same thing using the newer MongoCollection. 但是,我似乎无法使用较新的MongoCollection完成相同的操作。

As per the new driver of MongoDB the API is bit changed Now we have to do 按照MongoDB的新驱动程序,API进行了更改,现在我们要做

collection.distinct("tokens.account_id",String.class).filter(new BasicDBObject("_id",new ObjectId(objectiId)))

Let me know if it works for you. 请让我知道这对你有没有用。

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

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