title: How do I make two operations on the same array element?
body: <p>I have MongoDB <code>users</code> collection with the (simplified) document structure:</p>
  <pre><code>{
    _id: ObjectId,
    name: 'John Doe',
    sportsList: [ // array of objects
      {
        name: 'football',
        level: 1500,
        levelHistory: [ // array of objects
          {
            from: 1450,
            to: 1500,
            date: Date
          },
          ...
        ]
      },
      {
        name: 'tennis',
        level: 1400,
        levelHistory: [ // array of objects
          {
            from: 1350,
            to: 1400,
            date: Date
          },
          ...
        ]
      },
    ]
  }
  </code></pre>
  <p>I want to update the element of <code>sportsList</code> that has the <code>name === 'tennis'</code> like this:</p>
  <ul>
  <li>push a new element into <code>levelHistory</code></li>
  <li>update the <code>level</code>
  So far I've managed to push a new element into <code>levelHistory</code> with this query:</li>
  </ul>
  <pre><code>await User.updateOne(
    {
      _id: userId,
      sportsList: {
        $elemMatch: { name: 'tennis' }
      }
    },
    {
      $push: {
        'sportsList.$.levelHistory': {
          date: Date,
          from: 1400,
          to: 1450
        }
      },
      // how do I set 'level: 1450' in the same query?
      // if I tried to use a $set: { 'sportsList.$.level': 1450 } mongoDB throws an error
    }
  )
  </code></pre>