I am trying to seed a uuid using sequilize generateUUID
but i get this error Seed file failed with error: sequelize.Utils.generateUUID is not a function TypeError: sequelize.Utils.generateUUID is not a function
how do i seed a UUID?
return queryInterface.bulkInsert('companies', [{
id: sequelize.Utils.generateUUID(),
name: 'Testing',
updated_at: new Date(),
created_at: new Date()
}]);
Seed files are some change in data that can be used to populate database tables with sample or test data. Let's create a seed file which will add a demo user to our User table. npx sequelize-cli seed:generate --name demo-user. exports = { up: (queryInterface, Sequelize) => {
Extends: src/data-types.js~ABSTRACT → UUID. A column storing a unique universal identifier.
Since it's included in the DataTypes
package, would make sense to use what is already available as Matt suggested. You can use it in this way:
{
...,
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With