gpt4 book ai didi

mongodb - MongoTemplate 查找不返回结果

转载 作者:行者123 更新时间:2023-12-04 18:09:50 25 4
gpt4 key购买 nike

MongoTemplate 不返回结果。

JSON:

{
"_id" : ObjectId("51acf6ab0d5d46077ae12b2a"),
"docType" : "row",
"value" : {
"entity" : {
"@id" : "1111",
"@version" : "3434",
"name" : "XY XY",
"listId" : 28,
"listCode" : "BS",
"entityType" : "03",
"createdDate" : "09/12/2006",
"lastUpdateDate" : "04/20/2011",
"source" : "CCC",
"address1" : "XXXXXXXX",
"city" : "CITY",
"country" : "CO",
"countryName" : "COUNTRY NAME"

}
},
"createdDate" : ISODate("2013-06-03T20:03:55.127Z"),
"createdBy" : "Test"
}

查询:

queryy = new Query(Criteria.where("docType").is("row").andOperator(Criteria.where("value.entity.city").is("CITY")));

以上查询不返回任何结果。

我错过了什么吗?请帮忙。

最佳答案

试试这个:

query = new Query(Criteria.where("docType").is("row")
.and("value.entity.city").is("CITY"));

您的代码不需要 andOperator 函数(因为它转换为 $and)。它只需要使用 的多个条件。

而且,您可以使用 query.toString() 来查看查询的输出结果(并将其与您可能在 MongoDB shell 中使用的结果进行比较。

关于mongodb - MongoTemplate 查找不返回结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17111294/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com