title: MongoDB update with condition
body: <p>I'm trying to update some field in my collection depending on a condition.</p>
  
  <p>I want to set field <code>active</code> to <code>true</code> if the condition is <code>true</code> and to <code>false</code> otherwise </p>
  
  <p>This is update without condition</p>
  
  <pre><code>db.consent.update(
  {}, //match all
  {
      $set: {
          "active": true
      }
  }, 
  {
      multi: true,
  }
  
  )
  </code></pre>
  
  <p>I would like to add a condition to update like this:</p>
  
  <pre><code>db.consent.update(
  {},
  $cond: {
      if: {
  
          $eq: ["_id", ObjectId("5714ce0a4514ef3ef68677fd")]
  
      },
      then: {
          $set: {
              "active": true
          }
      },
      else: {
          $set: {
              "active": false
          }
      }
  }, 
  {
      multi: true,
  }
  </code></pre>
  
  <p>)</p>
  
  <p>According to <a href="https://docs.mongodb.org/manual/reference/operator/update-field/" rel="noreferrer">https://docs.mongodb.org/manual/reference/operator/update-field/</a> there is no <code>$cond</code> operator for update.</p>
  
  <p>What are my options here to execute this update as a single command?</p>