gpt4 book ai didi

node.js - 错误 : null value in column "id" violates not-null constraint in sequelize

转载 作者:搜寻专家 更新时间:2023-11-01 00:41:17 41 4
gpt4 key购买 nike

我试图在 sequelize 中将主键的数据类型更改为字符串,但在尝试使用 upsert 创建时出现以下错误。

error:  SequelizeDatabaseError: null value in column "id" violates not-null constraint 

代码如下:

 id: {
type: DataTypes.STRING,
primaryKey: true,
allowNull: true,
autoIncrement: false,
field: "id"
}

我如何使它起作用?提前致谢。

最佳答案

对于 the documentation :

Technically, a primary key constraint is simply a combination of a unique constraint and a not-null constraint.

您不能创建可为空的主键。

  ...
allowNull: false,
...

关于node.js - 错误 : null value in column "id" violates not-null constraint in sequelize,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33662670/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com