繁体   English   中英

MongoDB:如何使用Java驱动程序获取包含数组的所有元素?

[英]MongoDB : how to get all elements that contain an array using Java Driver?

您将如何使用Java驱动程序编写此MongoDB查询:

db.customers.find({'arrayName':{$ exists:true},$ where:'this.arrayName.length> 0'})

干杯,扬

要使用Java驱动程序构建查询,您可以将所有Javascript对象替换为DBObject

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);

暂无
暂无

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

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