简体   繁体   中英

Mongodb java 3.0 driver misunderstanding

I am using the java 3.0 Mongodb driver, and trying to use distinct.

With the deprecated DBCollection I can do the following:

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.

As per the new driver of MongoDB the API is bit changed Now we have to do

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

Let me know if it works for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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