title: Mongoose Promise chaining fail to deleteMany
body: <p>For some reason my Promise chaining with Mongoose is not working.
  Running it a second time works. I am curious what I did wrong.
  Here's the code to recreate it. </p>
  
  <p>Schema</p>
  
  <pre><code>var blogSchema = new mongoose.Schema({
  title: String,   
  tag:[{  type: mongoose.Schema.Types.ObjectId,
          ref: "tag" }]});
  
  var tagSchema = new mongoose.Schema({
  tag: String,
  blog: [{ type: mongoose.Schema.Types.ObjectId,
          ref: "blog" }]})
  </code></pre>
  
  <p>Create dummy data. 1 blog and 2 tag with reference objectid to the blog.</p>
  
  <pre><code>var Blog = require("../models/blog") //create your own ref
  var Tag = require("../models/tag") //create your own ref
  
  myBlog = new Blog({title: '1st Post'});
  tag1 = new Tag({ tag: 'Tag 1' })
  tag2 = new Tag({ tag: 'Tag 2' })
  
  myBlog.tag.push(tag1);
  myBlog.tag.push(tag2);
  tag1.blog.push(myBlog);
  tag2.blog.push(myBlog);
  
  Promise.all([myBlog.save(), tag1.save(), tag2.save()])
          .then(() =&gt; {});
  </code></pre>
  
  <p>The goal of the code is to delete the blog objectid reference from both the tag, and if there's 0 elements of blog objectid, delete the tag as well.</p>
  
  <pre><code>let foundBlog
  Blog.findOne({ title: '1st Post' })
     .then((blog) =&gt; {
         foundBlog = blog;
      })
     .then(() =&gt; {
         Tag.updateMany( //remove BlogID from Tags
             { _id: { $in: foundBlog.tag } },
             { $pull: { blog: foundBlog._id.toString() } }).exec()          
      })
      .then(() =&gt; { //remove any Tags with 0 BlogID
              Tag.deleteMany({ "blog": { $size: 0 } }).exec()
      })    
  </code></pre>
  
  <p>Running this the first time did not delete my Tags. I believe Tag.deleteMany executed, but for some reason the Tags was not deleted even though there are 0 elements of blog objectid in both Tags, due to Tag.updateMany.</p>
  
  <p>However, running the same code the 2nd time successfully remove both Tag.</p>
  
  <p>Where did I go wrong? Clearly I must have either gotten my logic wrong or misunderstood how promises work? Any insights would be helpful. Thanks</p>