-
Type: Story
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Iteration Xylocarpus Granatum
-
Needed
-
mongosh currently allows users to load external JS files with the .load REPL command. This is, however, somewhat limited.
For example, I can't .load a JS file that contains .load commands inside.
The legacy mongo shell exposed a load() method that could be used anywhere, i.e. directly in the REPL as well as inside files loaded into the REPL. This provides a much better user experience as it gives developers the ability to modularize the code the load into the shell to customize its behavior.
In mongosh we should provide a similar functionality.
Acceptance criteria
- mongosh includes a load('<path to file>') method to load an external JS file into the shell
- When the load() method is called, the file passed as argument is loaded into the shell, parsed and executed
- Loaded files can contain other calls to load() to load other stuff
- load() calls are processed synchronously and the result of a load() of a file that loads other files inside is equivalent to a load() of a big file with the other loaded files copy-pasted in the same order as the related load() calls
- if the file passed to load() is not found or contains errors, mongosh prints out an error
- if a file loaded from a loaded file is not found or contains errors, mongosh prints out an error
Open questions
- Can we make load() work also in Compass and VS Code?
- is depended on by
-
MONGOSH-324 Support for .mongoshrc.js
- Closed