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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:31:57+00:00 2026-05-17T23:31:57+00:00

Suppose I follow users 4, 7, 10, and 20. How can I query that

  • 0

Suppose I follow users 4, 7, 10, and 20. How can I query that in Mongo?

db.all_posts.find(users = 4, 7, 10, 20).sort( by date )

I don’t know the right syntax. Is this scalable?

  • 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-17T23:31:58+00:00Added an answer on May 17, 2026 at 11:31 pm

    Use the $in operator to match against multiple values:

    db.all_posts.find({user: {$in: [4, 7, 10, 20]}}).sort({date: 1})
    

    As you can see, the find(), sort() and most other methods in MongoDB take in objects as parameters. These objects are called query expression objects.

    The question Making a Twitter-like timeline with MongoDB should answers your question about scalability, as it discusses the same data model as yours.

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

Sidebar

Related Questions

this is a follow-up question of mine. Suppose now I have a URL :
This is somewhat of a follow-up question to this question . Suppose I have
Suppose we got a original query as follows: SELECT A, B, C FROM tblA
This is a follow up to my previous question . Consider that I write
For iOS, I am aware that apps can upload in the background, as according
I'd like to persist pidl s between sessions, so that my application can remember
Can you share your thoughts how would you implement data versioning in Cassandra. Suppose
I'm currently trying to make a form called countcash that allows users to input
I'm creating a calendar where users can set events and time in single line,
I've got a little problem with correct query and hope you can help me.

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.