Select specific database in mongorc.js

mongo-shell, mongodb, nosql

Solution

The db-name is an option when starting the mongo javascript shell.

mongo

mongo --help

You can also do something similar like this from the js file

db = db.getSiblingDB("dbname")

Problem

Is it possible to select a database that MongoDB should use on startup in the mongorc.js? ``` use dbname ``` is not functioning. This is a Non-JavaScript macro.

Original source