I have a javascript file and want to run them inside a mongo shell. I know how to load the javascript file during connection from this link: How to execute mongo commands through shell scripts?. But my case is how to run an external js file after the connection already established.
My js file looks like below:
db.getSiblingDB("test")
.enron_messages.find({
$or: [{ filename: "111." }, { "headers.From": "test@gmail.com" }]
})
.sort({ "headers.To": 1 })
.limit(10);
and in my mongo shell, I use load('test.js')
to load that file but it returns true(see below output). How to execute this file?
> load('test.js')
true