title: MongoDB: update dictionary in document
body: <p>I have a MongoDB document that saves occurrences of some things in a dictionary:</p>
  
  <pre><code>{
    "id" : 1,
    "occurrences" : {
      "1" : 1,
      "2" : 5,
      "17" : 1,
      "35" : 4
    }
  }
  </code></pre>
  
  <p>I now want to add or update some entries, for example add a "12:3" to the occurrences, or update the number of occurrences of "17" to 2, so let's say as an example I want to add {"12":3} and {"17":2} to this dictionary.
  It is driving me crazy because I simply can not get it to work. I could use arrays and all that, but I would really like to have it in this particular design. Any ideas on how to solve this? I tried so many different things with $set and $each and so on.</p>