Robomongo: Unable to use db with hypens in name from shell

Created on 15 Feb 2017  路  8Comments  路  Source: Studio3T/robomongo

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:

  1. Create a database called i.e. my-database
  2. Open a shell in Robomongo
  3. Type use my-database

You'll see an error message saying: Error: Line 1: Unexpected identifier

Is this a bug that can be fixed? Or is there any workaround?

bug enhancement

Most helpful comment

Hi @henningst,
thanks a lot for reporting issue! I reproduced your problem, and can suggest the next workarounds:

  1. Shell: use next queries
db = db.getSiblingDB("my-database")   
db.myCollection.find()

Please see references here.

  1. 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!

All 8 comments

Hi @henningst,
thanks a lot for reporting issue! I reproduced your problem, and can suggest the next workarounds:

  1. Shell: use next queries
db = db.getSiblingDB("my-database")   
db.myCollection.find()

Please see references here.

  1. 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!

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:

  1. Shell: use next queries
db = db.getSiblingDB("my-database")   
db.myCollection.find()

Please see references here.

  1. 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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fabritw picture fabritw  路  3Comments

kphamilton picture kphamilton  路  3Comments

andidev picture andidev  路  3Comments

lborg019 picture lborg019  路  4Comments

equero picture equero  路  3Comments