Executing JavaScript file in MongoDB
javascript, mongodb, nosql
Solution
I usually run my test queries like this, and it works with your sample code too.
mongo < test.js
Problem
I would like to know how to execute a JavaScript file in MongoDB. This is the simple piece of code present in my JS file: ``` function loadNames() { print("name"); } ``` From the command prompt I tried to execute the file like this ``` mongo test.js ``` but it shows the error: unexpected identifier Can anyone explain to me where I'm going wrong?