Reputation: 955
I created a collection named "stats" but whenever I try to delete it by using db.stats.drop()
cmd line. It shows an error.
TypeError: db.stats.drop is not a function
Even tried this.
db["stats"].drop
Any solution?
Upvotes: 1
Views: 260
Reputation: 3815
if the collection exists db.stats.drop() should work (depending on the mongodb version maybe) or else perhaps db.getCollection("stats").drop();
but if all else fails, run: db.runCommand({drop : "stats"})
this should drop it if it exists without any error at least.
Upvotes: 2