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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:23:06+00:00 2026-05-18T22:23:06+00:00

My question is related to http://jira.mongodb.org/browse/SERVER-991 . I need a nested array of a

  • 0

My question is related to http://jira.mongodb.org/browse/SERVER-991. I need a nested array of a fixed size storing latest XX events related to current document.

How can I implement client-side this feature? I thought of maintaining a count on array size, something like:

  1. Select count field from element
  2. Push element to embedded array
  3. If count < XX, then inc_count; Else, pop latest element;

The downsides of this approach:

  • 3 queries for each event push
  • as mongo doesn’t have transactions, the array could have either less or more elements than allowed(in the same time, two clients push or pop elements) – but this doesn’t bother me very much

Could you comment on how this could be implemented?

  • 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-18T22:23:07+00:00Added an answer on May 18, 2026 at 10:23 pm

    You can preinitialize arrays with nulls and get rid of size checks. Just pop and push. This way you also avoid size growth and document relocations. Your client code will have to handle null-terminated arrays properly.

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

Sidebar

Related Questions

My Question is related to the HTTP Streaming Method for realizing HTTP Server Push:
This question is related to Cross-Origin Resource Sharing (CORS, http://www.w3.org/TR/cors/ ). If there is
As a follow up question related to my question regarding efficient way of storing
My question is related to this discussion: http://www.cocoabuilder.com/archive/cocoa/202211-how-to-get-nsurl-form-nsurlconnection.html I am sending several NSURLConnections to
I got a CSS question related to this fiddle: http://jsfiddle.net/r584e/ Here the relevant screenshot
I asked a question related to this one previously but I need to know
We have a very special question related HTTP meta tags. A content-language meta tag
(See related question: How do I report an error midway through a chunked http
This question is related to my last one about jQuery 1.4. They supposedly fixed
NOTE: I have a related question here (http://stackoverflow.com/questions/6915055/are-jsf-views-shared-between-users) but that deals with a few

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.