Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select specific database in mongorc.js

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.

like image 901
hellectronic Avatar asked Sep 25 '26 07:09

hellectronic


1 Answers

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")

like image 56
Scott Hernandez Avatar answered Sep 26 '26 22:09

Scott Hernandez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!