Scala Slick. Wrong pagination \\w Postgres

孤街醉人 提交于 2019-12-08 20:48:28

The issue is that you are sorting after taking your values. If, in the initial order, 39 is in the 21st position and you take and sort the first 20 values, it cannot be sorted into the correct place, as you sort without it there.

If you want correct ordering, you should sort your users before taking the chunks, e.g:

val sortedUsers = users.sortBy(_.id.desc)
sortedUsers.drop(0).take(20).list
sortedUsers.drop(20).take(20).list
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!