How to delete a collection which ends with a "."

I am on v1.33.1 of MongoDB Compass and it allowed me to create a view that ends with a “.”
Now when I am trying to open the view or do any operations on it. It says "Collection names must not start or end with ‘.’ "
I tried deleting using the compass as well as CLI using the command db[‘collection name.’].drop() and it failed with the above message for both.
I guess this is a bug in MongoDB Compass where it won’t validate the name while creating the view and validates on operations and delete.

Try square bracket notation
Check this link

You can try

db.getCollection('collection name.').drop()

@Massimiliano_Marcon Doesn’t work. I wonder why it allowed me to create it first of all

Tried those methods, but nothing seems to work.

Yes, Compass should not let you create that view. We’ll fix it.

In the meantime, you should be able to delete it with

db.runCommand({drop: 'Adv Alts Detection.'})

It worked, thank you very much.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.