I can't drop a view with two consecutives dots in the name

I’ve accidentally named a view : “test…view”. When I try to delete it now I get the following error : MongoInvalidArgumentError: Collection names cannot be empty

I tried running the following command : db.getCollection("test..view").drop()

I also tried to rename it but got the same error.

But the error is still there.

Hi @Vincent_Perez, welcome to the forums.

Use runCommand to execute drop on the view:

test> show collections
test..v1          [view]
test..view        [view]
v1                [view]
test> db.runCommand({drop: 'test..v1'})
{ ns: 'test.test..v1', ok: 1 }
test> db.runCommand({drop: 'test..view'})
{ ns: 'test.test..view', ok: 1 }
test> show collections
v1                [view]

thanks, I finally succeded in deleting it via a node script modifying my mongo node module.
Indeed the problem seems to come from the client you’re using.
Your solution is cleaner. Thanks

1 Like

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