aravindnc / mongoose-paginate-v2

A custom pagination library for Mongoose with customizable labels.

Home Page:https://www.npmjs.com/package/mongoose-paginate-v2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Edge case with changed limit on second page

chdanielmueller opened this issue · comments

Hi there,

I hit an edge case where someone used a result limit of 5 items, navigated to page 2, changed the limit to 10 items and can not navigate backwards.

Current:
offset = 5, limit = 10
-> hasPrevPage = false, prevPage = null

Expected:
offset = 5, limit = 10
-> hasPrevPage = true, prevPage = 1

I have already written a test for this case and the solution.
PR follows shortly.

Cheers,
Daniel