title: How do you add a collection in Mongoose?
body: <p>I'm trying to clear my Users collection before and after my tests:</p>
  
  <pre><code>before(function(done) {
    mongoose.connection.collections['users'].drop(function(err) {
      mongoose.connection.collections['users'].insert(user, done);
    });
  });
  
  after(function(done) {
    mongoose.connection.collections['users'].drop(done);
  });
  </code></pre>
  
  <p>I also tried it without the <code>drop</code> in the <code>before</code>:</p>
  
  <pre><code>before(function(done) {
    // mongoose.connection.collections['users'].drop(function(err) {
      mongoose.connection.collections['users'].insert(user, done);
    // });
  });
  
  
  after(function(done) {
    mongoose.connection.collections['users'].drop(done);
  });
  </code></pre>
  
  <p>I'm getting these errors:</p>
  
  <pre><code>1) Auth API "before all" hook:
       TypeError: Cannot read property 'drop' of undefined
        at Context.&lt;anonymous&gt; (server/api/auth/auth.spec.js:18:45)
  
    2) Auth API "after all" hook:
       TypeError: Cannot read property 'drop' of undefined
        at Context.&lt;anonymous&gt; (server/api/auth/auth.spec.js:24:45)
  </code></pre>
  
  <p>My code was working before, and now it isn't. How can I create the collection?</p>
  
  <hr>
  
  <p>Update: I ran <code>db.collection.users.insert({ foo: 'bar' })</code> in the command line, and now it looks like the collection and document exist:</p>
  
  <p><a href="https://i.stack.imgur.com/rD8Dz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rD8Dz.png" alt="enter image description here"></a></p>
  
  <p>But I'm still having the same problem.</p>
  
  <hr>
  
  <p>Update 2: This worked:</p>
  
  <pre><code>before(function(done) {
    // mongoose.connection.collections['users'].drop(function(err) {
    //   mongoose.connection.collections['users'].insert(user, done);
    // });
    User.remove({}).exec(function() {
      User.create(user, done);
    });
  });
  </code></pre>
  
  <p>Now when I run the old code, it also works:</p>
  
  <pre><code> before(function(done) {
    mongoose.connection.collections['users'].drop(function(err) {
      mongoose.connection.collections['users'].insert(user, done);
    });
  //   User.remove({}).exec(function() {
  //     User.create(user, done);
  //   });
  });
  </code></pre>
  
  <p>There's something weird going on here...</p>