【发布时间】:2019-05-26 07:17:07
【问题描述】:
使用 nodejs(10.15.0)、sequelize (4.42.0) 和 MySQL,我正在尝试从连接查询的结果中删除表路径。
Table1
.findAll({
attributes: ['id', 'name', 'other'],
include: [{
attributes: ['code_id'],
model: Table2,
nested: false,
required: true,
}],
raw: true,
})
查询结果
[
{
"id": 1,
"name": "stuff",
"other": true,
"table2.code_id": 1,
}
]
期待发生
[
{
"id": 1,
"name": "stuff",
"other": true,
"code_id": 1,
}
]
【问题讨论】:
-
尝试将
as: "code_id"作为属性添加到includes-array 中的对象。
标签: mysql node.js sequelize.js sequelize-typescript