We can run script from terminal using:
mongo localhost:27017/db_name script_name.js > result
and
mongo localhost:27017/db_name < script_name.js > result
The first one is running the script without input pipe and the second one using input pipe.
I noticed that it will behave differently with and without input pipe.
For example,
- without input pipe, you can put block comment /* … */
- without input pipe you can declare function anywhere in your script but with input pipe you must declare it before you call the function
- without input pipe mongo will show error on which line if it failed to run the script
- with input pipe mongo will show detail result
Is there any documentation for these? I want to know the different when using input pipe and not using it.