在 sequelize 中是否可以使用 Nested eager loading 对 Nested 请求进行分页?
in sequelize is it possible to paginate the Nested request using Nested eager loading?
我正在使用 Nested eager loading 功能,这是续集示例:
User.findAll({
include: [{
model: Tool,
as: 'Instruments',
include: [{
model: Teacher,
where: {
school: "Woodstock Music School"
},
required: false
}]
}]
}).then(function(users) {
/* ... */
})
假设您想要执行 endpoint
'summary' 并且您想要包含 Teacher model
,但只包含前三个结果
是否可以仅使用嵌套预加载?
Sequelize提供了实现这个目的的方法?
试了很多东西,我得出的结论是不能直接做。
您可以在教师模型中使用 limit 和 offset
User.findAll({
include: [{
model: Tool,
as: 'Instruments',
include: [{
model: Teacher,
where: {
school: "Woodstock Music School"
},
limit: 3,
required: false
}
]
}
]
}).then(function (users) {
/* ... */
})
我正在使用 Nested eager loading 功能,这是续集示例:
User.findAll({
include: [{
model: Tool,
as: 'Instruments',
include: [{
model: Teacher,
where: {
school: "Woodstock Music School"
},
required: false
}]
}]
}).then(function(users) {
/* ... */
})
假设您想要执行 endpoint
'summary' 并且您想要包含 Teacher model
,但只包含前三个结果
是否可以仅使用嵌套预加载?
Sequelize提供了实现这个目的的方法?
试了很多东西,我得出的结论是不能直接做。
您可以在教师模型中使用 limit 和 offset
User.findAll({
include: [{
model: Tool,
as: 'Instruments',
include: [{
model: Teacher,
where: {
school: "Woodstock Music School"
},
limit: 3,
required: false
}
]
}
]
}).then(function (users) {
/* ... */
})