Per*_*öjd 4 json has-many express sequelize.js
我有以下与续集相关的模型。
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
Run Code Online (Sandbox Code Playgroud)
这些表已成功连接,我可以从中检索数据。但是当我检索 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
}
}
Run Code Online (Sandbox Code Playgroud)
因此,如果可能,我正在寻找一种方法来隐藏这些“character_attending_boss”段,最好不要更改提取后的结果。
这可能吗?
同样的问题在这里解决:https : //github.com/sequelize/sequelize/issues/2541
对我来说,添加through: {attributes: []} 包含块在 Sequelize 2.0 上效果很好
| 归档时间: |
|
| 查看次数: |
785 次 |
| 最近记录: |