Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

271
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda