title: Mongoose: what's up with "_doc"?
body: <p>It seems Mongoose is doing something really funky internally.</p>
  <pre><code>var Foo = new mongoose.model('Foo', new mongoose.Schema({a: String, b: Number}));
  var foo = new Foo({a: 'test'; b: 42}); 
  var obj = {c: 1};
  foo.goo = obj;                  // simple object assignment. obj should be 
                                    //   passed by reference to foo.goo. recall goo
                                    //   is not defined in the Foo model schema
  
  console.log(foo.goo === obj);   // comparison directly after the assignment
      // =&gt; false, doesn't behave like normal JS object
  </code></pre>
  <p>Essentially, any time you try to deal with properties of a Mongoose model that aren't</p>
  <p>a) defined in the model's schema or</p>
  <p>b) defined as the same type (array, obj, ..) ... the model doesn't even behave like a normal Javascript object.</p>
  <p>Switching line <strong>4</strong> to <code>foo._doc.goo = obj</code> makes the console output <code>true</code>.</p>
  <p><strong>edit</strong>: trying to reproduce weirdness</p>
  <p><strong>example 1</strong>:</p>
  <pre><code> // Customer has a property 'name', but no property 'text'
   // I do this because I need to transform my data slightly before sending it
   // to client.
   models.Customer.find({}, function(err, data) {
       for (var i=0, len=data.length; i&lt;len; ++i) {
          data[i] = data[i]._doc;            // if I don't do this, returned data
                                             // has no 'text' property
          data[i].text = data[i].name;       
      }
      res.json({success: err, response:data});
  });
  </code></pre>