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 8087289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:43:46+00:00 2026-06-05T18:43:46+00:00

I am storing Tweets in a MongoDB database, and would like to use Field

  • 0

I am storing Tweets in a MongoDB database, and would like to use Field Selectors (http://www.mongodb.org/display/DOCS/Querying#Querying-FieldSelection) to return just the text, the date and the screen name of the user.

{ 
    "_id" : NumberLong("213686009408"), 
    "text" : "RT @Milanello: Lightning over the Donb...", 
    "created_at" : "Fri, 15 Jun 2012 17:37:38 +0000", 
    "user" : { 
        "screen_name" : "xxxxx", 
        "profile_image_url" : "http://a0.twimg.com/pro[...].jpg"
    }
}

Creating a query that returns just the text and date is easy enough:

> db.abc.find({},{created_at:1,text:1})

I’m not sure how to return the user.screen_name property as well?

[UPDATE]

I had previously tried using the dot notation and it threw an exception, however, as per both answers below (I have +1’d both) the dot notation does work, but only if you use “” around the attribute names.

So, this does NOT work:

db.abc.find({},{created_at:1,text:1, user.screen_name:1})

But this DOES:

db.abc.find({},{created_at:1,text:1, "user.screen_name":1})
  • 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-06-05T18:43:48+00:00Added an answer on June 5, 2026 at 6:43 pm

    You can use dot notation as you would in a query:

    db.abc.find({},{created_at:1,text:1, "user.screen_name" : 1})
    

    However, the field will not be flattened, so the result objects still have a user-subdocument:

    { "_id" : NumberLong("4546545"), 
      "created_at" : "Fri, 15 Jun...", 
      "user" : { "screen_name" : "John Doe" } 
    }
    

    However, flattening this in code shouldn’t be a big problem.

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

Sidebar

Related Questions

I've been playing around storing tweets inside mongodb, each object looks like this: {
I am using google app engine and would like to download tweets from a
Is storing secret keys (internal use passwords and such) on iPhone source code and
Im storing columns in database with users able to add and remove columns, with
I am storing data in Sqlite Database along with the date of insertion. The
I'm storing some passwords in a database using PHP+MySQL I realise that MD5 is
I would like to store the raw JSON stream (either via Twitter or the
I'm building my first android app - something that will display my tweets in
I need to save in real-time to a database all tweets from the Twitter
I have a simple mongodb collection which stores tweets directly from the twitter api

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.