michaelklishin/monger

Pagination returning the same keys in monger

zendevil opened this issue · 0 comments

I’m doing a db query using the monger library like so:

(q/with-collection db "videos"
             (q/find {})
             (q/sort {:date 1})
             (q/paginate :page page :per-page 5))

However, when I do page 1, I get the following ids:

("6011a14028dacb0004d7475c"
"6011a1ea28dacb0004d7475d"
"60119fe128dacb0004d7475a"
"602a15665273b0b82c3ded1c"
"6011a0b428dacb0004d7475b")

when I do page 2, I get these:

("6011a14028dacb0004d7475c"
"60119fe128dacb0004d7475a"
"602a15665273b0b82c3ded1c"
"6011a0b428dacb0004d7475b"
"60124ed4afa8e90004ab71a0")

The problem is that there’s an overlap of ids between the two pages. I expect the pages to show ids with no overlap. How to fix this?