0

I have a Document in the form of :-

{
  "_id": "5926db7249f80521d8045bb7",
  "env": "local",
  "url": "....",
  "iP": "xxxxxxxx",
  "dailyReports": [
   {
    "criteria": "XYZ",
    "skip": "0",
    "pass": "9",
    "fail": "6",
    "typeOfExecution": "Daily"
   }
   ]
}

I want to update the value of pass, skip and fail every time the env matches and the criteria is matched with the execution. So I used the following to access the collection and using update one :-

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

The mongoDailyReportCollection is pointing to the collection correctly but I am unable to update the values of the pass, fail and skip fields.

Using mongo driver 3.4.1 and java

Sourajyoti Bose
  • 83
  • 2
  • 10

0 Answers0