title: How to add a property (property name is variable) to object via MongoDB driver (node.js)
body: <p>The structure of my document in collection is this.</p>
  
  <pre><code>{ 
  "_id" : ObjectId("54e74de2950fd3a4e5f0a37a"),
  "userName": "Any_user",
  "ratings": {
     "rating1" : [ ],
     "big_rating" : [ ] 
    }
  }
  </code></pre>
  
  <p>In MongoDB client (mongo.exe) the adding i need looks like this</p>
  
  <pre><code>db.userContent.update({userName: "NXTaar"}, {$set: {"ratings.variable_name": []}})
  </code></pre>
  
  <p>I need the function for the MongoDB node.js driver
  And yes, i know the "property name as string" thing there i can pass the variable to the property name. Here is what i tried to make:</p>
  
  <pre><code>var rating = {};
  var title = 'some_string';
  ratings[title] = [];
  
  usercontent.update({userName: "some_user"}, {$set: ratings}, function (err, doc) {...})
  </code></pre>
  
  <p>this line adds a new object to the document with a name of property</p>
  
  <pre><code>usercontent.update({userName: "some_user"}, {$set: {ratings: ratings}}, function (err, doc) {...})
  </code></pre>
  
  <p>and this one does exactly what i need, but each time it runs, it rewrites current property with a new one(yes, i know, it because of $set parameter which changes selected object with the thing that you've passed to it)</p>
  
  <p>I need a function which adds a property to object with a name given through variable</p>