Ricky
Ricky

Reputation: 777

dropping a mongo collection with a "?" at the end of its name

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'

Upvotes: 0

Views: 154

Answers (1)

nbkhope
nbkhope

Reputation: 7474

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.

Upvotes: 1

Related Questions