title: Update array inside a mongoose document
body: <p>I have a mongoose schema which has a field like so</p>
  <pre><code>    Week1ScheduleEntries: [{
            PlayerName: String,
            Slots: { type: Array, default:[]}
          }],
  </code></pre>
  <p>I am trying to update the <code>Slots</code> array based on a certain condition, inside a <code>for</code> loop. This is what I have tried so far:-</p>
  <pre><code>    for (let i=0; i&lt;activeTournamentRecord.Week1ScheduleEntries.length; i++){
            playerIsActive = false
            let idNumber = activeTournamentRecord.Week1ScheduleEntries[i]._id
            if(activeTournamentRecord.Week1ScheduleEntries[i].PlayerName === player){
              console.log(idNumber)
              playerIsActive = true
              try{
                  const updatedTournamentRecord = await Tournament.findOneAndUpdate({_id: idNumber},
                    {$set: {&quot;Slots&quot;: {&quot;Slots&quot;: slotArray }} }
                  )
              } catch (err) {
                const error = new HttpError(
                  'Cant Find Tournament. ',
                  500
                );
                return next(error);
              }
              break
            }
  </code></pre>
  <p>The <code>$set</code> is unfortunately not working. Am I missing something? Can someone help?</p>