• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

215
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 3 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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda