Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongo shell - TypeError - not a function

So I'm trying to tidy up my database.

I logged into shell, made a show collections request and then I wanted to delete some of those.

I used db.collection_name.drop() and it helped for a while. A dozen of collections were deleted successfully. But then I got to a collection called "stats".

db.stats.drop() brings error E QUERY [js] TypeError: db.stats.drop is not a function : @(shell):1:1

The only difference with previous successful drops is the collection name. So I'm guessing maybe it's a reserved word or something? How do I drop it? I thought shell is the best way to do such things.

like image 802
Dmitriy M Avatar asked Dec 05 '25 18:12

Dmitriy M


1 Answers

db.getCollection("stats").drop() did the job

like image 199
Dmitriy M Avatar answered Dec 08 '25 08:12

Dmitriy M



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!