I've got the following models associated with sequelize.
我有以下与sequelize相关的模型。
Event hasMany Characters through characters_attending_boss
Boss hasMany Characters through characters_attending_boss
Characters hasMany Event through characters_attending_boss
Characters hasMany Boss through characters_attending_boss
These tables are successfully joined and I can retrieve data from them. But when I retrieve the JSON-results the name of the through model gets added to each object, like this:
这些表已成功连接,我可以从中检索数据。但是当我检索JSON结果时,直通模型的名称会添加到每个对象中,如下所示:
{
id: 1
title: "title"
-confirmed_for: [ //Alias for Event -> Character
-{
id: 2
character_name: "name"
-confirmed_for_boss: [ // Alias for Boss -> Character
-{
id: 9
name: "name"
-character_attending_event: { // name of through-model
event_id: 1
char_id: 2
}
}
]
-character_attending_boss: { // name of through-model
event_id: 1
char_id: 2
}
}
So I'm looking for a way to hide these "character_attending_boss" segments if possible, preferably without altering the results post-fetch.
所以我正在寻找一种方法来隐藏这些“character_attending_boss”段,如果可能的话,最好不要改变后取的结果。
Is this possible?
这可能吗?
2 个解决方案
#1
4
Same issue is solved here: https://github.com/sequelize/sequelize/issues/2541
同样的问题在这里解决:https://github.com/sequelize/sequelize/issues/2541
For me adding through: {attributes: []}
to include block works well on Sequelize 2.0
对我来说,添加:{attributes:[]}以包含块在Sequelize 2.0上运行良好
#2
1
Pass { joinTableAttributes: [] }
to the query.
将{joinTableAttributes:[]}传递给查询。
#1
4
Same issue is solved here: https://github.com/sequelize/sequelize/issues/2541
同样的问题在这里解决:https://github.com/sequelize/sequelize/issues/2541
For me adding through: {attributes: []}
to include block works well on Sequelize 2.0
对我来说,添加:{attributes:[]}以包含块在Sequelize 2.0上运行良好
#2
1
Pass { joinTableAttributes: [] }
to the query.
将{joinTableAttributes:[]}传递给查询。