Answers for "pagination method in sequelize"

1

sequelize pagination postgres

const limit = 10;
const offset = (req.body.page - 1) * limit;

const result = await Posts.findAndCountAll({
  offset: offset,
  limit: limit,
  order: [
    ['date', 'ASC']
  ]
});
Posted by: Guest on April-07-2021
0

Limits and Pagination in Sequelize

// Fetch 10 instances/rows
Project.findAll({ limit: 10 });

// Skip 8 instances/rows
Project.findAll({ offset: 8 });

// Skip 5 instances and fetch the 5 after that
Project.findAll({ offset: 5, limit: 5 });
Posted by: Guest on June-14-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language