title: How to remove a field that is populate (mongoose)
body: <p>I have two schemas that are related to each other. And I am having trouble removing the related field. I have an article model and a note model and I would like to delete notes based on article id.</p>
  
  <pre><code>var article = new Schema({
  title:{
      type:String,
      required:true
  },
  summary:{
      type:String
  },
  link:{
      type:String,
      required:true
  },
  note:{
      type: Schema.Types.ObjectId, 
      ref: 'Note' 
  
   }
  })
  
  var note = new Schema({
    title:String,
    body:String
  
  })
  </code></pre>
  
  <p>So far I have tired do the following in my server.js file</p>
  
  <pre><code>var db = require("./models");
  
  app.delete("/articles/:id",function(req,res){
      var id = req.params.id;
      db.Article.findById(id)
      .then(function(dbArticle){
          var noteId = dbArticle.note;
          db.Note.findByIdAndRemove(noteId);
  
          console.log("success")
      })
      .catch(function(err){
          res.json(err);
      })
  </code></pre>
  
  <p>So far I am not successful.</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>app.delete("/articles/:id",function(req,res){
    var id = req.params.id;
     db.Article.findById(id)
       .then(function(dbArticle){
          var noteId = dbArticle.note;
          return db.Note.findByIdAndRemove(noteId);
      }).then(
          function(){
              res.json({ "message": "success" })
          })
      .catch(function(err){
          res.json(err);
      })
  </code></pre>
  
  <p>});</p>