Is this possible to write the query result to the file from mongo js script. I have searched a lot, but I didn\'t find any solution.
ex:-
cursor = db
You can skip the while loop using forEach():
forEach()
db.users.find().forEach(printjson);