// Here it is hardcoded for example but
// generally the `pageNum` should come from request query param
const pageNum = 2;
const pageSize = 10;
// pagination formula
const paginate = (pageNum - 1) * pageSize;
// Query
const data = await DataModel
.find()
.skip(paginate)
.limit(pageSize)
Last active
January 14, 2021 15:31
-
-
Save rocktimsaikia/6f0b0c53dab89aad3d485a5b84372fad to your computer and use it in GitHub Desktop.
🔥 How to paginate in mongodb using mongoose
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment