You could use print and then redirect output:
script.js:
cursor = db.users.find();
while(cursor.hasNext()){
printjson(cursor.next());
}
then run the script and redirect output to a file:
mongo --quiet script.js > result.txt
You could use print and then redirect output:
script.js:
cursor = db.users.find();
while(cursor.hasNext()){
printjson(cursor.next());
}
then run the script and redirect output to a file:
mongo --quiet script.js > result.txt