Sequelize pagination

The easiest way to do this is to use Sequelize’s findAndCountAll

Post.findAndCountAll({
    where: {...},
    order: [...],
    limit: 5,
    offset: 0,
}).then(function (result) {
    res.render(...);
});

Here, result has both the result of your query and count as result.rows and result.count. You can then increment the offset and use this for pagination.

Sequelize documentation for findAndCountAll

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)