如何进行嵌套包含? 我有表产品与评论有一对多关系,表评论与用户表有多对一关系。 所以评论有 user_id 和 product_id。 我的代码是这样的
var models = require('../models');
models.products.findAll({
include: [
{model: models.comments}
]
}).then(function (products) {
next(products);
}).catch(function (err) {
next(err);
});
});
我收到了评论,但我想有类似的东西
models.products.findAll({
include: [
{model: models.comments.include(models.comments.users)}
]
})
这是否可以在不编写自定义查询的情况下实现?
最佳答案
models.products.findAll({
include: [
{model: models.comments, include: [models.comments.users] }
]
})
关于javascript - 嵌套包含在sequelize中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33941943/