mongodbmongo-shellmongosh

MongoDB: drop collection created with special characters


How do I drop the Mongo collection created with special characters?

Collection name: arpit^Crxcurrencies02

I tried:

db.arpit^Crxcurrencies02.drop();

Error:

ReferenceError: Crxcurrencies02 is not defined


Solution

  • Use db.getCollection() and then drop():

    db.getCollection("arpit^Crxcurrencies02").drop()
    

    mongodb shell output