I can run the script in the specific database like
mongo main myscript.js<br/>
where main
is a database name. The same thing I am unable to run inside the script like
use main; // not taking, throw error when using "mongo myscript.js"
Use this in your script
db = db.getSiblingDB('main');
The default DB is test
. This statement gets a "sibling" database of test
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With