Sequelize在define时默认一直有个主键“id”,可是MySQL表分区又不允许有主键。 求去掉表主键,还能正常使用Sequelize的方法!!!
回复 (2)
文档里都写了 http://docs.sequelizejs.com/en/v3/docs/legacy/#primary-keys
And if your model has no primary key at all you can use Model.removeAttribute('id');
L
引用 jkeylu__legacy_55273449cde195f05a17f302文档里都写了 http://docs.sequelizejs.com/en/v3/docs/legacy/ primary keys And if your model has no prim...
@jkeylu 用“removeAttribute”确实可以删除默认主键id,但在查询时使用“include”就会报错:
Unhandled rejection SequelizeDatabaseError: ER_BAD_FIELD_ERROR: Unknown column 'alarm_handle.id' in 'field list'
其中,alarmhandle 为删除主键的表名。
参与回复
登录后即可参与回复。登录