Can I read the csv file inside the Mongo Shell Javascript file?

I basically have a string file and I need to query mongo to find out if they exist in our database.

So, I need to scroll through the file and request a manga with the search query using a line from the file, and then look at the results and increase some of the counters that I have.

I am trying to do this using a shell script and calling mongo using the --eval option, but it is slow. More than an hour passed and 120,000 requests did not end. I think it would be faster if I could do this in a javascript file, so it does not need to establish a connection for each request.

Thanks for any suggestions!

Karen

+4
source share
2 answers

cat().

, /home/desktop/myfile.txt

row1
row2
row3
row4

var:

$> var string = cat('home/desktop/myfile.txt');
$> string = string.split('\n');
$> db.records.find({field: {$in: string}});
+5

, , mongoimport. , CSV , .

0

Source: https://habr.com/ru/post/1598913/


All Articles