2

I read this similar question: Sequelize Unknown column '*.createdAt' in 'field list'

but the solution doesn't work for me! Why? This is my code:

 var User = sequelize.define("User", {
    id: {
      type: DataTypes.UUID,
      primaryKey: true
    },
    cognome: DataTypes.STRING,
    nome: DataTypes.STRING,
    email: DataTypes.STRING,
    password: DataTypes.TEXT,
    stato: DataTypes.INTEGER,
    ruolo: DataTypes.INTEGER
  }, { 
    freezeTableName: true 
  }, {
    timestamps: false
  });

the error is:

Executing (default): SELECT `id`, `cognome`, `nome`, `email`, `data_nascita`, `password`, `cellulare`, `stato`, `blacklist`, `createdAt`, `updatedAt` FROM `Candidato` AS `Candidato`;
Unhandled rejection SequelizeDatabaseError: ER_BAD_FIELD_ERROR: Unknown column 'createdAt' in 'field list'
0

1 Answer 1

4

Instead of passing { timestamps: false } as an additional param of Sequelize.define call, you should extend the existing (third) one with the corresponding property:

var User = sequelize.define("User", {
  // model definition skipped
}, { 
    freezeTableName: true,
    timestamps: false
});

... as it described in the docs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.