如何从结果中排除 child 的 child?
How can I exclude child's child from the result?
我正在使用 MySQL 数据库将 Sequelize 集成到 express 项目中。
调用模型的find方法时出现问题
结果包含所有嵌套的 children。但我想从结果中删除 child 的 child。
这是我尝试执行但失败的代码。
return await db.tutorial.findAll({
include: [{ model: Tag, as: 'tag', nested: false}]
})
这是结果的屏幕截图。
如何设置包含过滤器选项以从结果中排除 child 的 child 信息?
如果你愿意,我可以分享更详细的信息。
我自己找到了解决方案。
我通过如下编辑 include 语句解决了这个问题:
return await db.tutorial.findAll({
include: [{
model: Tag,
as: 'tag',
through:{
attributes: []
}
}]
})
感谢您的关注。 :)
我正在使用 MySQL 数据库将 Sequelize 集成到 express 项目中。
调用模型的find方法时出现问题
结果包含所有嵌套的 children。但我想从结果中删除 child 的 child。
这是我尝试执行但失败的代码。
return await db.tutorial.findAll({
include: [{ model: Tag, as: 'tag', nested: false}]
})
这是结果的屏幕截图。
如何设置包含过滤器选项以从结果中排除 child 的 child 信息?
如果你愿意,我可以分享更详细的信息。
我自己找到了解决方案。 我通过如下编辑 include 语句解决了这个问题:
return await db.tutorial.findAll({
include: [{
model: Tag,
as: 'tag',
through:{
attributes: []
}
}]
})
感谢您的关注。 :)