0

I can't figure out how to drop a collection named "did-it-break?"

I've tried the usual way:

db.did-it-break?.drop()

but no, its not working. it outputs

[thread1] SyntaxError: expected expression, got keyword 'break'
Ricky
  • 717
  • 3
  • 10
  • 21
  • 3
    Possible duplicate of [Working with special characters in a Mongo collection](https://stackoverflow.com/questions/9569976/working-with-special-characters-in-a-mongo-collection) – s7vr Feb 07 '18 at 00:05

1 Answers1

1

Simply reference the collection name using brackets instead of the dot:

db['did-it-break?'].drop()

Always use brackets if you cannot type some name using the dot notation.

nbkhope
  • 7,360
  • 4
  • 40
  • 58