title: Update multiple docs in a collection using switch case
body: <p>I use MongoDB native driver in my NodeJS application.</p>
  
  <p>I have a <code>shifts</code> collection in my database that I need to update. Sample docs in my shifts collection</p>
  
  <pre><code>{
      "_id" : ObjectId("588425105560bd2ba0065fa4"),
      "from" : ISODate("2017-01-23T03:20:00.000Z"),
      "to" : ISODate("2017-01-23T06:20:00.000Z"),
      "jobId" : ObjectId("586efda790541421b0432897"),
      "hourlyRate" : 15
  }
  
  {
      "_id" : ObjectId("588425105560bd2ba0065fa5"),
      "from" : ISODate("2017-01-25T03:20:00.000Z"),
      "to" : ISODate("2017-01-25T06:20:00.000Z"),
      "jobId" : ObjectId("586efda790541421b0432897"),
      "hourlyRate" : 15
  }
  </code></pre>
  
  <p>What I need to do is the following - </p>
  
  <p>Update the <code>hourlyRate</code> of all docs that meet the conditions:</p>
  
  <ul>
  <li>match the jobId (that is easy) </li>
  <li>set <code>hourlyRate</code> = 20 if <code>from</code> is a Weekday </li>
  <li>set <code>hourlyRate</code> = 25 if <code>from</code> is a Saturday </li>
  <li>set <code>hourlyRate</code> = 30 if <code>from</code> is a Sunday</li>
  </ul>
  
  <p>I would want to do it in a single query as far as possible.</p>
  
  <p><strong>My solution so far:</strong></p>
  
  <p>Use switch case and determine the type of day using <code>$dayOfWeek</code> from Date aggregation function. However, I am not able to combine switch with <code>updateMany</code>.</p>
  
  <p>Any help would be appreciated.</p>