title: mongodb set field value using if else during document update
body: <p>Is there a way in mongodb to use if/else to set a field value during an update.
  i know that i can use find, to return  documents, loop over them, and do if/else check on each and make a new save query for each of the documents.</p>
  <p>However, that seems wasteful, if there is a way to update conditionally in one go.</p>
  <p>Is it possible to conditionally set a field value, e.g like this</p>
  <pre><code>Documents.update(
      {some_condition: true}, 
      {$set: {&quot;status&quot;: 
          {$cond: 
                {if  : {&quot;some field&quot;: &quot;some condition&quot;}},
                {then:  &quot;value 1&quot;} ,
                {else: &quot;value 2&quot;} 
          } 
      }} 
  )
  </code></pre>
  <p>(I know that $cond is used for aggregation, i used it here as an example of what i have in mind.)</p>