Node Sequelize that does not allow auto-generated UUIDs on the primary key * if * the field name is not equal to 'id'

This Sequelize commit seems to confirm that naming the primary key 'id' makes it special. And, based on my tests with the following snippet, changing the field name to something other than "id" is enough so that the default value is not set, and therefore the inserts do not work.

id: { type: DataTypes.UUID, primaryKey: true, defaultValue: DataTypes.UUIDV4, allowNull: false }

So, is there a way to keep the flexibility of naming primary key fields and using UUID by default?

+6
source share

Source: https://habr.com/ru/post/974709/


All Articles