我的文件格式为: -
{
"_id": "5926db7249f80521d8045bb7",
"env": "local",
"url": "....",
"iP": "xxxxxxxx",
"dailyReports": [
{
"criteria": "XYZ",
"skip": "0",
"pass": "9",
"fail": "6",
"typeOfExecution": "Daily"
}
]
}
我希望每次env匹配时更新pass,skip和fail的值,并且条件与执行匹配。 所以我使用以下内容访问集合并使用更新: -
this.mongoDailyReportCollection.updateOne(and(eq("env", dailyReport.getEnvName()),
eq("dailyReports.dateOfExecution", dailyReport.getCriteria())),
combine(set("dailyReports.pass", dailyReport.getPass()),
set("dailyReports.fail", dailyReport.getFail()),
set("dailyReports.skip", dailyReport.getSkip())));
mongoDailyReportCollection正确指向集合,但我无法更新pass,fail和skip字段的值。
使用mongo驱动程序3.4.1和java