Ability to execute a javascript file from inside the shell
Currently the only way to execute a javascript file from the mongo shell is to re-direct the input at shell login time (e.g. mongo --username <username> ... < myscript.js). It would be helpful to have a way to execute the script from inside the shell via some sort of "run" command (e.g.from inside the shell "run /my/path/myscript.js".
4
votes
Greg
shared this idea
Mongosh 0.10.0+ supports load() which seems to be exactly what you need. Please let me know if that is not what you had in mind.
-
Greg commented
Looks good to me.
-
AdminMassimiliano (Admin, MongoDB) commented
In `mongo`, you can call `load('/my/path/myscript.js')` and we are planning to support the same or a similar API in `mongosh`.
Is that close enough to what you are looking for?