Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

278
Views
Pagination: How to know if there are more documents in a mongoDB collection?

How can I know if there're more documents in mongo query that implements limit()

Is there a way to know if there are more documents available for pagination in MongoDB?. Following the example shared in this post, I somehow still end up getting a false flag but I am sure there's a next page

  let pagelimit = number || 10
  const items = db.find({}).sort({ _id: 1 }).limit(pagelimit).toArray()
 
  items.length > page limit + 1 // false
  items.length > page limit // false

Tried items.length > page limit + 1 and items.length > page limit they both still return a false but there are definitely more items in the db.

Any pointers on how to go about this?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!