How would you write this MongoDB query using Java driver :
db.customers.find({'arrayName' : {$exists:true}, $where:'this.arrayName.length>0'})
Cheers, Yann
To build a query with the Java driver, you substitute any Javascript objects with DBObject
's.
DBObject condition = new BasicDBObject();
condition.put("arrayName", new BasicDBObject("$exists", true));
condition.put("$where", "this.arrayName.length>0");
DBCursor result = yourDatabase.getCollection("customers").find(condition);
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.