Node.js Sequelize查询不适用于分页
我正在尝试使用node.js/sequelize对查询进行分页。以下是工作代码(未分页): 我尝试了以下操作,但发现连接被拒绝错误:Node.js Sequelize查询不适用于分页,node.js,pagination,sequelize.js,Node.js,Pagination,Sequelize.js,我正在尝试使用node.js/sequelize对查询进行分页。以下是工作代码(未分页): 我尝试了以下操作,但发现连接被拒绝错误: async index (req, res) { try { const data = await UserFile.findAll({ attributes: ['rec_id', ['User_File.user_id', 'client_id'], doc_name, created_on], offse
async index (req, res) {
try {
const data = await UserFile.findAll({
attributes: ['rec_id', ['User_File.user_id', 'client_id'], doc_name, created_on],
offset: 5,
limit: 5,
order: ['created_on', 'DESC']
})
res.status(200).json(data)
} catch (err) {
res.status(500).json(data)
}
},
我还需要在分页版本中进行连接,但不确定如何…属性必须是单引号“doc_name”,“created_on”。它还应该是db.UserFile.findAll。@Prabhjot Singh Kainth我添加了“”和db,仍然是相同的错误。
async index (req, res) {
try {
const data = await UserFile.findAll({
attributes: ['rec_id', ['User_File.user_id', 'client_id'], doc_name, created_on],
offset: 5,
limit: 5,
order: ['created_on', 'DESC']
})
res.status(200).json(data)
} catch (err) {
res.status(500).json(data)
}
},