我先用sequelize-auto 生成对应关系,只会运行时发现表的字段名写的有误,于是重新命名了表的字段名。将createdAt 改成了created_at当我再次测试api的时候,发现sequelize对sql的查询语句出错了,如下Executing (default): INSERT INTO `user` (`id`,`username`,`password`,`created_at`,`updated_at`,`createdAt`) VALUES (DEFAULT,'admin','12345',1507738177512,1507738177512,'2017-10-11 16:09:37');server error { SequelizeDatabaseError: Unknown column 'createdAt' in 'field list'即,createdAt这个字段还在sequelize里面,并没有被删除掉。求解。
1 回答
缥缈止盈
TA贡献2041条经验 获得超4个赞
原来sequelize会默认自动添加createdAt和updatedAt,这两个我的表里面没有,所以会报错。
By default, Sequelize will add the attributes createdAt and updatedAt to your model so you will be able to know when the database entry went into the db and when it was updated last.
添加回答
举报
0/150
提交
取消