I’m using mongoDB on an ubuntu server. However I’m using a javascript to store data and do some map/reduce. I would like to measure these operations and write the results into a file. Somehow I fail to open a file and write into it.. I tried the following:
f = new File("myfile.txt");
if(f.open("w") == true)
{
f.write("test");
f.Close();
}
The
fileobject within spidermonkey (the JS engine MongoDB uses, and coincidently the console) has been made obsolete: https://developer.mozilla.org/en-US/docs/SpiderMonkey/File_object . Not only that but it wasn’t standard to spidermonkey anyway so that was a long shot.As @gkamal states, the best way is to pipe the output of the MongoDB console like so: