Wrong Document getting added to MongoDb
<p>I have been beating my head around this code but I am unable to figure out the solution to the problem that I am facing.</p>

<p>I have the following schema for the mongoDb document.</p>

<pre><code>{

    "brand" : "String",
    "series" : "String",
    "model" : "String",
    "deviceType" : "String",
    "progress" : "Number",
    "uploaded" : []

}
</code></pre>

<p>Following is the function that i am using for adding the document to the  database</p>

<pre><code>var addData = function(details){
    console.log(details);
    var promise = new Promise(function(resolve, reject){
        var document = new Document({

            brand : details.brand,
            series : details.series,
            model : details.model,
            devicetype : details.devicetype,
            progress : 0,
            uploaded : []

        });

    //save the document into the database
    document.save(function(err, document){
        if(err){
            reject(err);
        }
        else{
            console.log('document added--' + document);
            console.log('document should be--' + details);
            resolve('Document added successfully');
        }

    });

})
return promise; 
}
</code></pre>

<p>The details object that I am using to populate the document is coming out as follows</p>

<pre><code>{ brand: 'HP',
  series: 'Elitebook',
  model: '8460P',
  devicetype: 'laptop',
  progress: 0,
  uploaded: [] }
</code></pre>

<p>But the document that is getting added is not as per the schema and one of the fields is missing in the document. Could some one please tell where I am going wrong. Following is the document that is getting added.</p>

<pre><code>document added--{ __v: 0,
  brand: 'HP',
  series: 'Elitebook',
  model: '8460P',
  progress: 0,
  _id: 5850f50f0a0d7f055c441b7c,
  uploaded: [] }
</code></pre>