We have some MongoDB databases with hyphens in the name. I.e. prefix-environment-customername. This haven't given us any issues until now, but today I tried to do some operations to a database through the console in Robomongo and found out I'm unable to select databases with hyphens in the name.
Steps to reproduce:
my-databaseuse my-databaseYou'll see an error message saying: Error: Line 1: Unexpected identifier
Is this a bug that can be fixed? Or is there any workaround?
Hi @henningst,
thanks a lot for reporting issue! I reproduced your problem, and can suggest the next workarounds:
db = db.getSiblingDB("my-database")
db.myCollection.find()
Please see references here.
Let me known if these tips work for you!
The getSiblingDB method works and solves my problem. Thanks!
Faced with the same problem
same here: cannot create db with hyphen in name: use my-database.
same here: version 4.0.5
same here. any resolution?
worked fine 4 me ! 10x !!
Hi @henningst,
thanks a lot for reporting issue! I reproduced your problem, and can suggest the next workarounds:
- Shell: use next queries
db = db.getSiblingDB("my-database") db.myCollection.find()Please see references here.
- GUI: if you just double-click to list all documents in collection, shell will be switched to use proper db.
Let me known if these tips work for you!
It's not worked on windows 10 (via SSH) for names like some-db:topic
Most helpful comment
Hi @henningst,
thanks a lot for reporting issue! I reproduced your problem, and can suggest the next workarounds:
Please see references here.
Let me known if these tips work for you!