You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SELECT `users`.*, `userDetails`.`userId` AS `userDetails.userId`,`userDetails`.`firstName` AS `userDetails.firstName`, `userDetails`.`id` AS `userDetails.id`, `userDetails`.`createdAt` AS `userDetails.createdAt`, `userDetails`.`updatedAt` AS `userDetails.updatedAt` FROM `users` LEFT OUTER JOIN `userDetails` AS `userDetails` ON `users`.`id` = `userDetails`.`userId`;
报错:
在使用sequelize创建model后,使用model进行findAll查询的时候报错:
报错原因:
在sequelize中启用了时间戳(即sequelize中创建的model开启了时间戳),但是在数据库中的实际表定义不包含时间戳列。
当你做model.findAll时,会将model中的每一进行别名查询(也包括model中开启的时间戳),从而创建下面例子查询,这面就包含了数据库中实际没有的时间戳列(createdAt,updatedAt):
解决办法
在model创建的时候禁用时间戳,例如禁用userDetails模型的时间戳:
或在sequelize连接mysql的时候,直接禁用所有时间戳开启:
The text was updated successfully, but these errors were encountered: