sequelize: defaultValue: Sequelize.UUIDV4 not working?

I’m using the following model with a sqlite3 backing:

var models = {
    Ink: sequelize.define("Ink", {
      id: { type: Sequelize.UUID, defaultValue: Sequelize.UUIDV4 },
      company: Sequelize.TEXT,
      inkname: Sequelize.TEXT,
      profiles: Sequelize.ARRAY(Sequelize.UUID),
      notes: Sequelize.ARRAY(Sequelize.UUID)
    }),
   ...
};

but the following code leads to a record without an autogenerated id:

var ink = models.Ink.build({
  company: "a",
  inkname: "b"
});

ink.save().complete(function() {
  console.log(ink.company, ink.inkname, ink.id);
});

The console log shows a b null instead.

It gets even more fun when I try id: { type: Sequelize.UUID, allowNull: false, defaultValue: Sequelize.UUIDV4 } because it ends up null anyway.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 18 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Ho my… I’m so sorry, I wrote “v4” with a lower “v”. That’s why it does not work. Good night of sleep helped.