我正在尝试将sequelize升级到v5.8.10,并将sequelize-typescript升级到v1.0.0-beta.3。 在新版本中,表名似乎是复数的。如何恢复以前的行为?
我在这里发布:https://github.com/sequelize/sequelize/issues/11083 没有答案
const dbUser = await User.scope("auth").findOne({ where: { email: "john@domain.com" } });
预期结果:
SELECT "id", "email" FROM "User" AS "User" WHERE ("User"."email" = 'john@domain.com');
实际结果:
SELECT "id", "email" FROM "Users" AS "User" WHERE ("User"."email" = 'john@domain.com');
当然还有sql错误:
ERROR: relation "Users" does not exist
答案 0 :(得分:1)
现在创建Sequelize对象时有一个选项:
define: {
freezeTableName: true //prevent sequelize from pluralizing table names
},