Pagination Flashcards
(3 cards)
1
Q
What is pagination?
A
It is dividing a dataset into small equal parts, so that the parts are sent to the clients in separate pages rather than all at once
2
Q
How do you send a pagination request from the URL?
A
URL?page=val&limit=val
3
Q
How would you handle a pagination request in Mongoose?
A
if(req.query.page){const page = Number(req.query.page) || default value;const limit = Number(req.query.limit) || default value;const skip = (page - 1) * limit;query = query.skip(skip).limit(limit);}