How can I go to the next page?
leonardomso opened this issue · 5 comments
Describe the bug
There's no available method to go to the next page.
To Reproduce
const options = {
page: 1,
limit: 10,
sort: { createdAt: -1 },
lean: true,
};
await IDModel.paginate({}, options).then(
({ docs, page, totalPages, totalDocs, hasNextPage, nextPage }) => {
...
},
);
Expected behavior
I am trying to paginate over a large collection of documents and I want to go to the next page after all the operations are done.
@leonardomso To go to next page pass {page: 2} in options.
Ok, but how can I know that there's a next page available outside the paginate
? We shouldn't have a method available inside the callback function that would go to the next page?
If the return value is having hasNextPage=true, the you have a next page. I'd suggest you to go through the plugin documentation again.
I have an array of documents, I'd like to paginate over them, for example, with a limit of 10 documents, and do a specific operation. After that operation, I would like to go to the next page and do the same operation, until all the documents are gone and there's no next page.
How could I do that?
Please go through the documentation, everything is explained there with sample code. Should be stratight forward for you.