Suppose my file contains the following data and is located at /home/usr1/Documents/companyNames.txt
Name1
Name 2
Name 3
Countless names...
I attempted to use this code:
$> var string = cat('home/usr1/Documents/companyNames.txt');
$> string = string.split('\n');
$> db.records.find({field: {$in: string}});
According to the code in the link Can I read a csv file inside of a Mongo Shell Javascript file?
This method works fine for small files, but when dealing with files containing millions of lines, it crashes as all the lines try to fit into memory. Is there an alternative way to process large files within the Mongo shell using JavaScript?