How to run a local script in mongo shell - Solution load()

Viewed 12335

I think this is a very basic question but I'm stuck. I'm connected to remote mongo instance (mLab) via a MongoDB shell. This has been fine for one-liners, but now I want to run larger commands but often, thus the need to do it from an already connected shell.

How can I run my local script.js from the mongo shell and get the output in the shell, as if I'm just running the one-liner per usual?

I was hoping load("script.js") would do it, but it just returns 'true' regardless of the content.

1 Answers
Related