title: Update Whole Document in MongoDb
body: <p>I am trying to insert and update document in mongodb using node.js. I can successfully insert the document using the following code.</p>
  
  <pre><code>var obj = { jsonit: 
              { users: {},
                groups: {},
                meta: 
                    { id: 'daf09a36-b961-3db4-3144-aa19479c70c7'},
                name: 'John Doe',
                meta: undefined,
                loki: undefined
             }
  Collection.insert( obj ).then( function insertCollectioncb(object) {
          obj = object;
        });
  </code></pre>
  
  <p>After that i want to update the whole document as i don't know which keys will be change or which new keys will be inserted. I am using following code to update my document.</p>
  
  <pre><code>var obj = jsonit: 
         { users: {},
           groups: {},
           meta: 
               { id: '0da70a1f-f5cd-0fd2-10c8-7aa421296057'} ,
          name: 'John Doe',
          creationDate: '2016-10-13T11:05:08.453Z',
          income: 1000,
          meta: null,
          loki: null 
        }
  Collection.update( { _id: '57ff860b240e9d50a42ec53c' }, obj ).then( function updateBranchcb(object) {
          obj = object;
        });
  </code></pre>
  
  <p>I can do it successfully in mongo shell but can't do it through node js.</p>