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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:10:56+00:00 2026-06-02T23:10:56+00:00

I have a collection with 1000 items. I want to sort them per date

  • 0

I have a collection with 1000 items. I want to sort them per date (SaveDateUtc field) and remove the top 10 of them, so I’m left with the 990 newest items in my collection.

I could do a Find and then a Remove, no problem, but it’d be much better if I could do this with just a Remove call. But I can’t find a way to sort and set top 10 through the query.

So my question is, can I do this in just one call?
(I’m using the C# driver)

  • 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-02T23:10:58+00:00Added an answer on June 2, 2026 at 11:10 pm

    Actually there was similar question: MongoDB find and remove – the fastest way

    But unfortunately findAndUpdate cannot be restricted by records number. So my propositions to you:

    • You may introduce some surrogate field so you could use it as field in query
    • You may write you own java-script server-side function that will do this operation on server side. Benefits – operation is done on server, it is atomic. Pitfall – it is not works with sharded tables.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm planning to have collection of items stored in a TCollection. Each item will
I have two Collection objects, I want to associate each object of these two
I have a collection of checkboxes with generated ids and some of them have
I have a collection of string. I want to create an image out of
I have an application that encrypts a collection of files, zips them up and
I have a massive collection of methods that I want to shape into a
I have a collection of synopses that are about 1000 char long each. In
If I have an Order class an as aggregate root and 1000 line items.
So I have a ListView with an upper limit of about 1000 items. I
Here is my dilemma. I have a collection of entities that I want 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.