this code will show the error am facing the collection which am trying to delete is 'Coimbatore Express' and problem is I have a space between Coimbatore & Express.
The db. collection. remove() method is used to remove documents from a collection.
The drop command removes the specified collection or view from the federated database instance storage configuration.
In MongoDB, you are allowed to delete the existing documents from the collection using db. collection. deleteMany() method. This method deletes multiple documents from the collection according to the filter.
Either try using a dot(.
) operator to replace the space.
db.Coimbatore.Express.drop()
Or alternatively as mentioned in the documentation use getCollection
as:
db.getCollection("Coimbatore Express").drop()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With