MongoError: ns not found when try to drop collection

Mongoose throw an error i.e, "MongoError: ns not found" when i try to drop collection.

Here is my mongoose code:

var mongoose = require('bluebird').promisifyAll(require('mongoose'));
......
......
......   
mongoose.connection.db.dropCollection("myCollection",function(err,affect){
   console.log('err',err);

})

Error:

err { [MongoError: ns not found]
name: 'MongoError',
message: 'ns not found',
ok: 0,
errmsg: 'ns not found' }


MongoError: ns not found occurs when performing actions on collections that don't exist.

For example, attempting to drop indexes before an explicit collection creation has occurred or before adding a document to the collection which implicitly creates the collection.


Status(ErrorCodes::NamespaceNotFound, "ns not found"); is thrown when you try to drop a collection, a view or an index that doesn't exist.

For example: _dropCollection

Other than that, there is no need to explicitly check if a collection already exists before doing any CRUD operations.