How to implement cursor orientation using Sequelize

I was looking for a way to implement pagination using Sequelize and Postgres, I cannot find clear, basic examples of how to do this. I know there are npm packages that can help, but there seems to be no clear instruction on how to use them.

+4
source share
1 answer

Here is an example of a paginated query I made a while ago:

const findAll = (page, successCallback, errorCallback) =>  {
  sequelize.Event.findAll({
    limit: 20,
    offset: 20*page,
    where: {
      /* ... */
    },
    order: [
      /* ... */
    ]
  })
  .then(events => successCallback(events))
  .catch(err => errorCallback(err));
};
0
source

Source: https://habr.com/ru/post/1677111/


All Articles