title: How to Update array field in MognoDB using Java Spring Boot?
body: <p>I want to Update <code>Scan</code> to <code>true</code> if qr Code is scan i have issue with query . </p>
  
  <pre><code>@GetMapping("/scannQr/{audienceId}/{eventName}/{Date}")
  
  public ResponseBody scannQr(@PathVariable String audienceId , @PathVariable String eventName , @PathVariable String Date) {
      Map&lt;String, Object&gt; result = new HashMap&lt;&gt;();
      Update update = new Update();
      Audience audience  = audienceRepository.findByAudienceIdAndEventName(audienceId, eventName);
      //check Audience if his name in database
      if(audience == null) {
          result.put("Sorry Can`t found Audience", audience);
          return new ResponseBody("failed",null);
      }
      for(int count = 0 ; count&lt;audience.getQrCodes().size() ; count++) {
           Map&lt;String , Object&gt; xx = (Map&lt;String, Object&gt;) audience.getQrCodes().get(count);
           //System.out.println("Key is :"+xx.get(audience.getAudienceName()+"Day"+count));
           //System.out.println(LocalDate.now());
           //System.out.println(LocalDate.now() +" == " + xx.get(audience.getAudienceName()+"Day"+0));
           String DateForToday = LocalDate.now().toString();
  
           if(DateForToday.equals(xx.get(audience.getAudienceName()+"Day"+count).toString()) &amp;&amp; xx.get("Scan").equals(false)) {
               System.out.println("Iam in For Loop");
               update.set(xx.get("Scan").toString(), true);
  
               System.out.println(update.set(xx.get("Scan").toString(), true));
              // Query to Update Scan = false to Scan True
               Query query = new Query();
                  query.addCriteria(Criteria
                          .where("audienceId").is(audienceId));
               System.out.println(query);
  
  
               mongoOperation.findAndModify(query, update, Audience.class);
               result.put("success", audience);
               return new ResponseBody("success",result);
           }
           if(DateForToday.equals(xx.get(audience.getAudienceName()+"Day"+count).toString()) &amp;&amp; xx.get("Scan").equals(true) ) {
               result.put("Qr For this Day But is Scanned", null);
               return new ResponseBody("failed",result);
           }
      }
      result.put("Qr is not for this Day", null);
      return new ResponseBody("failed",result);
  
  }
  </code></pre>
  
  <pre><code> "status": "success",
      "result": {
          "success": {
              "audienceId": "5e8e478509270606a25334bf",
              "eventName": "skills",
              "audienceName": "wesam",
              "audienceEmail": "wesam@gmail.com",
              "audienceNumber": "0796945849",
              "qrCodes": [
                  {
                      "Scan": false,
                      "mohammad qabbaniDay0": "2020-04-09"
                  },
                  {
                      "Scan": false,
                      "mohammad qabbaniDay1": "2020-04-10"
                  }
              ],
              "pathQr": "var/www/html/storage/PRQRS/skills",
              "link": "test.com/mohammad qabbani/null"
          }
      }
  }
  </code></pre>