title: How to stop MongoDB to add values to my objects?
body: <p>I'm writing a little personal project requiring to write into a db and getting content to be displayed with d3js. So I'm using objects containing like <code>{x: "2004-10-02", y:20}</code> etc... Now I found that mongoDB adds  <code>y0:0</code> and even  <code>y1: 20</code> when I change the value of <code>y</code> using  <code>$set</code> with Mongoose. </p>
  
  <p>I have this <code>Schema</code>:</p>
  
  <pre><code>var projectSchema = mongoose.Schema({
     key : String, 
     description: String,
     values: [{x: Date, y: Number, comment: String}]
  });
  </code></pre>
  
  <p>It works fine. I can insert documents (incomplete model) sending a request with this body: </p>
  
  <pre><code>{
      name: "name of the Project", 
      description: "insert descritption"
  }
  </code></pre>
  
  <p>and process the request with this: </p>
  
  <pre><code>var newProjectDetails = req.body;
  var np = new Project(newProjectDetails);
  np.save(function (err) {
    if (err) {
          return err;
    }
    else {
      console.log("Project saved");
    }
  });
  </code></pre>
  
  <p>then I add values to the <code>values</code> array (see above the Schema) and it works fine the first time, but if I try to overwrite an entry in the array I get this a messed object, with extra values that seem to be old values of the <code>y</code> property. </p>
  
  <p>Here's how I add an entry into the <code>values</code> array: </p>
  
  <pre><code>Project.findByIdAndUpdate(req.body._id, 
     { $set: { values: req.body.values } }, 
     function(err, tank){
       if(err){
         res.send(err);
       } 
         res.send(tank);
     })
  </code></pre>
  
  <p>But then when I fetch the content I got a strange issue inside the array:</p>
  
  <p>I get this object in the console: </p>
  
  <pre><code>  {
      "x": "2014-10-12T00:00:00.000Z",
      "y": 20,
      "comment": "doanjas dfgixGHWXV",
      "_id": "543a96c3a402c9ad17528d52"
    }
  </code></pre>
  
  <p>and this in RestWebServiceClient extention in Chrome: </p>
  
  <pre><code>{
    "x": "2014-10-12T00:00:00.000Z",
    "y": 20,
    "comment": "doanjas dfgixGHWXV",
    "_id": "543a96c3a402c9ad17528d52"
  }
  </code></pre>
  
  <p>But inside the console, when I iterate through the collection with Angular I get this: </p>
  
  <pre><code>{ _id: "543a96c3a402c9ad17528d52", 
    comment: "doanjas dfgixGHWXV", 
    series: 0,
    size: 20, 
    x: "2014-10-12T00:00:00.000Z", 
    y: 20, 
    y0: 0, 
    y1: 20
  }
  </code></pre>
  
  <p>This is driving me crazy, should I map the array and get rid of this, why would I do that extra work? </p>