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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:06:30+00:00 2026-05-25T21:06:30+00:00

I have the following collection for a user in a MongoDB: { _id :

  • 0

I have the following collection for a user in a MongoDB:

{
  "_id" : 1,
  "facebook_id" : XX,
  "name": "John Doe",
  "points_snapshot" : [{
      "unix_timestamp" : 1312300552,
      "points" : 115
    }, {
      "unix_timestamp" : 1312330380,
      "points" : 110
    }, {
      "unix_timestamp" : 1312331610,
      "points" : 115
    }]
}

Is it possible to write one query which by which I can get the user for id 1 along with the snapshots after a particular day. eg: 1312330300?

Basically limit the snapshots to X numbers matching some criteria?

So far, I have tried in C#:

Query.And(
 Query.EQ("facebook_id", XX), 
 Query.GTE("points_snapshot.unix_timestamp", sinceDateTimeStamp)))
 .SetFields("daily_points_snapshot", "facebook_id")

which I soon realised will not work for what I want.

Any help will be appreciated!
Thanks!

EDIT: My Solution to this

If anyone is looking to get a quick fix to this, this is what I ended up doing:

var points = MyDatabase[COLLECTION_NAME]
                .Find(Query.EQ("facebook_id", XX))
                .SetFields("points_snapshot", "facebook_id")
                .FirstOrDefault();

if (points != null) {
        var pointsArray = points.AsBsonDocument["points_snapshot"].AsBsonArray
        .Where(x => x.AsBsonDocument["unix_timestamp"].AsInt32 > sinceDateTimeStamp)
        .ToList();

        return pointsArray;
}
  • 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-25T21:06:31+00:00Added an answer on May 25, 2026 at 9:06 pm

    Is it possible to write one query which by which I can get the user for id 1 along with the snapshots after a particular day. eg: 1312330300?

    Not possible.

    The problem here is that MongoDB queries return all matching Documents. Your Document contains an array of objects, but MongoDB does not treat these as “Documents”.

    Now, you can limit the fields that are returned, but in your case you actually want to limit the “portions of an array” that are returned.

    This is a long-outstanding issue, the JIRA ticket is here. The ticket is dated about 18 months ago and it continues to get pushed back. So if this type of query is critical to your architecture, you may have to re-design the architecture.

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

Sidebar

Related Questions

I have user document collection like this: User { id:001 name:John, age:30, friends:[userId1,userId2,userId3....] }
I have a collection of articles in MongoDB that has the following structure: {
I have the following select list. <%= select_tag(:editlevel,options_from_collection_for_select(Level.all, :id, :name)) %> When the user
I have a collection in MongoDb where data in the collection has the following
I have the following Json collection and I need to represent it as a
I have following code to remove group from collection. Technically, there should be no
Lets say we have the following models: (simplified) class Collection(models.Model): slug = models.SlugField() class
I have the following code: // // POST: /PlayRoundHole/Create [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(FormCollection collection)
I have the following List<int> collection and I need to find the highest integer
I have in my app/views/bar/index.html.haml the following %p= render partial: 'foo', collection: @foos the

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.