Tag: cockroachdb

在Node.js中使用SERIAL的外键违规

在继续使用cockroachdb示例为node.js使用sequelize orm构build应用程序时,我扩展了它以在模型之间添加关联。 主键是INT,通过unique_rowid()自动递增。 根据你的文档,这是你的SERIAL的实现。 同步我的模型后,我尝试使用以下代码创buildlogging: models.sequelize.sync({ force: true }) .then(function () { return models.Customer.create({ name: "Sample Customer" }) }) .then(function (result) { const id = parseInt(result.dataValues.id, 10) return models.Order.bulkCreate([ { subtotal: 100.00, customer_id: id }, { subtotal: 200.00, customer_id: id } ]) }) 当这运行,我得到“ error: foreign key violation: value [255737842446434300] not found in customers@primary [id] […]