title: Mongoose _doc property
body: <p>Let’s suppose that we have in the database a task stored and we want to delete it and check it's deleted. Everything works fine when I have all the code to access the Database in one module. Like this</p>
  
  <p><strong>task.spec.js  module</strong></p>
  
  <pre><code>task.doFindByIdAndDelete( id )
   .then (function( deletedTask ){ 
     console.log( JSON.stringify(deletedTask.name, null, 2)) ;
   })
   .fail (function( err ){ 
    console.log( err ) ;
   })
  </code></pre>
  
  <p><strong>task.js  module</strong></p>
  
  <pre><code>var doFindByIdAndDelete = function(id){
   var deferred;
   deferred = Q.defer();
  
   TaskModel.findByIdAndRemove(id, function(err, modelDeleted){
    if(err){
      var error = "The model could not be deleted: ";
      deferred.reject(error + err);
    }
    deferred.resolve(modelDeleted);
   });
  
   return deferred.promise;
  };
  </code></pre>
  
  <p>With this code I can print the property 'name' of the ‘deletedTask’ without problems. But it results that the method ‘doFindByIdAndDelete’ works for all the elements in the database and I want to create a master function class that contains all the commons methods, and then ‘task’ will be an instance of this master class. The code is:</p>
  
  <p><strong>task.spec.js  module</strong></p>
  
  <pre><code>task.doFindByIdAndDelete( id )
   .then (function( deletedTask ){ 
     console.log( JSON.stringify(deletedTask.name, null, 2)) ;
   })
   .fail (function( err ){ 
     console.log( err ) ;
   })
  </code></pre>
  
  <p><strong>MasterModel.js module</strong></p>
  
  <pre><code>var MasterModel = function(Model){
   this.Model = Model;
  };
  
  MasterModel.prototype.doFindByIdAndDelete = function(id){
    var deferred;
    deferred = Q.defer();
  
    Model.findByIdAndRemove(id, function(err, modelDeleted){
      if(err){
        var error = "The model could not be deleted: ";
        deferred.reject(error + err);
      }
      deferred.resolve(modelDeleted);
    });
    return deferred.promise;
  };
  </code></pre>
  
  <p><strong>task.js  module</strong></p>
  
  <pre><code>var task = new ModelLogic(TaskModel);
  </code></pre>
  
  <p>In this version of the code when I call ‘doFindByIdAndDelete’ from task.spec.js I only can access the name property of deletedTask through the _doc property of the model, like deletedTask._doc.name</p>
  
  <p>This is a bug? Are there something wrong in my code?.  I have seen another posts of people with similar problems like </p>
  
  <p><a href="https://groups.google.com/forum/#!searchin/mongoose-orm/_doc/mongoose-orm/aq7rwxUnHTE/HoGXj6UTcu4J" rel="nofollow">https://groups.google.com/forum/#!searchin/mongoose-orm/_doc/mongoose-orm/aq7rwxUnHTE/HoGXj6UTcu4J</a></p>
  
  <p>but I couldn’t find a solution.
  Some ideas !!!</p>
  
  <p>Thanks 
  Toni</p>