Right now, I'm using mongodump
and bsondump
to get documents out of MongoDB, then applying regexes to the documents to get the value I want. What I really want is just a flat file of, say, the email address of every user in the users
collection, in a flat file that I can then manipulate with grep
, uniq
, etc.
In MySQL, it'd be:
mysql < query.sql > outfile.txt
The query.sql file would be something like:
SELECT email FROM users;
But in Mongo, when I pass a .js file in, I'm still not sure how to make it output single values.
mongo --db test < query.js > outfile.txt
What would query.js be for the users collection?