Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6754247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:15:26+00:00 2026-05-26T13:15:26+00:00

Right now, I’m using mongodump and bsondump to get documents out of MongoDB, then

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:15:27+00:00Added an answer on May 26, 2026 at 1:15 pm

    You could use forEach to run each result through a JavaScript function and print a line in the format you want:

    db.users.find().forEach(function(user) {
        print(user.email);
    });
    

    The --quiet command line option is also useful for removing the header lines from the output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I am using sqlite within a ios application, and I want to
Right now, to be sure I am getting what I want I am using
Right now, the background I get is a grey. I want to change it
Right now I have a script that will get the last five files in
Right now I'm using the following command to compile a coffeescript file each time
Right now I'm using OleDbDataAdapter objDataReader = new OleDbDataAdapter(); objDataReader.SelectCommand = myCommand; objDataReader.Fill(myDataTable); But
Right now I am only trying to get my getline() function to work. I
Right now I am using learning to program for the iphone and I am
Right now, I am buffering bytes using strings, StringIO, or cStringIO. But, I often
Right now, I'm using: TerminateProcess(pi.hProcess, 0) ... but this doesn't allow the application to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.