I have javascript that I load to mongo to get some info.
mongo --port=27017 script.js
I am passing ObjectIds from the file as a variable:
#script.js
db=connect('127.0.0.1:27017/dbname')
db.auth('user', 'pass') //get credentials
var file = cat('file_with_ids.txt'); // read the file
var objectId = file.split('\n');
for (var k =0, j = objectId.length-1; k<j; k++){
someFunction(objectId[k])
}
It works with files with (500K rows), but I have files with 1.5 M and more records that I need to work on. I was not successful finding documentation on mongodb cat() and its internals. I know that I can split the file into chunks and feed one by one using bash script, but I do not want to go that route. Limitations: I can only use pure JS, no node (could have been easier). I have written python code to do it, it works but python (pymonogo) reorders the order of the documents.
Any suggestions? How to solve this in pure JS? Thanks