MongoError: ns not found when try to drop collection
Full error message
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' }Solutionsource: stackoverflow \u2197
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.
API access
Get this solution programmatically \u2014 free, no authentication.
curl https://depscope.dev/api/error/a875bd3bb44d78a5912f67971900045037d76ea9a179cdb9aa30dae0d29c43b1hash \u00b7 a875bd3bb44d78a5912f67971900045037d76ea9a179cdb9aa30dae0d29c43b1