How to run the new `mongosh` with a JS file?

These do not work:

mongosh --shell consoletable.js
Current sessionID:  77dbd754f7b36b026be1b82f
Connecting to:      mongodb://consoletable.js:27017/test
mongosh consoletable.js --shell
Current sessionID:  77dc0556b638ce307878c5bc
Connecting to:      mongodb://consoletable.js:27017/test
mongosh consoletable.js
Current sessionID:  77df76ef26ae494504e8c4ec
Connecting to:      mongodb://consoletable.js:27017/test
3 Likes

That is currently not supported.

What you can try is to start mongosh and then from inside the shell do

> .load ./consoletable.js
2 Likes

The script needs to run as part of an automated build process. Any plans to implement this in the future?

Yes, definitely. One of our goals is feature-parity with the existing mongo shell.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.