Let say I have a java script file "mongo.js" where i print some data from mongoDb to the shell console.It's possible to save that output to a txt file? The js file content:
db = connect("localhost:27017/test");
var cursor=db.test.find();
cursor.forEach(
function(doc){
print(doc.name);
}
);
This is how I execute the file in mongo shell
load("mongo.js")
How to redirect the javascript output to a file? Tried so far:
mongo.exe --quiet mongo.js > file.txt
mongo.js > file.txt