title: mongodb update push array
body: <p>I have the following schema.  I am using node.js with mongodb</p>
  
  <pre><code>attributes: {
      type: { type: 'string' },
      title: { type:'string' },
      description: { type:'string' },
      is_active: { type:'boolean',defaultsTo:true },
      createdBy: { type:'json' },
      attachments:{ type:'array' }
  }
  
  arr = [{
      'id':attResult.id,
      'subtype':type,
      'title'  : attResult.title,
      'body'  : attResult.body,
      'filetype' : attResult.filetype
  }];
  </code></pre>
  
  <p>I am trying to push a attachments into the 'attachments' array that will be unique to the document.</p>
  
  <p>This is the my query.</p>
  
  <pre><code>books.update(
      { id: refid },
      { $push: { attachments: arr } }
  ).done(function (err, updElem) {
      console.log("updElem" + JSON.stringify(updElem));     
  });
  </code></pre>
  
  <p>What is the problem in my query,no error but not updated attachments.</p>
  
  <p>I want my result to be this:</p>
  
  <pre><code>{ 
      "_id" : 5,
      "attachments": [
          { 
              "id": "xxxxxxx",
              "subtype": "book",
              "title": "xxxx",
              "body": "xxxx" ,
              "filetype" : "xxxxx"
          },
          {
              "id": "xxxxxxx",
              "subtype": "book",
              "title": "xxxx",
              "body": "xxxx",
              "filetype": "xxxxx"
          }
      ]
  }
  </code></pre>