0
我在這個格式的文檔:MongoDB的投影不工作的Java
{
"env" : "local",
....,
"daily" : [
{
"executionParam1" : "Apple",
"executionParam2" : "sour",
"executionParam3" : "today",
...
},
{
"executionParam1" : "Oranges",
"executionParam2" : "sour",
"executionParam3" : "tomorrow",
....
}...
]
我使用MongoDB的Java驅動程序查詢。該查詢是這種形式:
this.mongoDailyReportCollection = this.mongoDb.getCollection("environments");
Bson projection = fields(excludeId(),
include("env", "daily"),
Projections.elemMatch("daily",
and(eq("executionParam1", coll.getexecutionParam1()),
eq("executionParam2", coll.getexecutionParam2()),
eq("executionParam3", coll.getexecutionParam3()))));
long count = this.mongoDailyReportCollection.count(projection);
我不斷收到計數爲0,即使executionParam1是蘋果,executionParam2是又酸又executionParam3是今天。如果我想更新與此相匹配的文檔,那麼過程如何?