[英]Find documents with array that contains a specific value in mongodb using java
According to the answer provided in this link: Find document with array that contains a specific value , i have tried getting the items in java using this statement 根据此链接提供的答案: 查找包含特定值的数组的文档 ,我尝试使用此语句获取java中的项目
searchQuery.put("arrayMine", new BasicDBObject("$in","[xxx]"));
OR
searchQuery.put("arrayMine", new BasicDBObject("$in","xxx"));
But it keeps saying the $in value must be an array while my arrayMine is an array. 但它一直说$ in值必须是一个数组,而我的arrayMine是一个数组。 What should be the correct syntax in java?
java中正确的语法应该是什么?
Both variants you have are treating the value of BasicDBObject
as String
. 您拥有的两种变体都将
BasicDBObject
的值视为String
。
Use 采用
searchQuery.put("arrayMine", new BasicDBObject("$in",Arrays.asList("xxx"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.