Node.js,sequelize和Unknown列

时间:2016-09-07 15:57:34

标签: node.js sequelize.js

我读到了类似的问题: Sequelize Unknown column '*.createdAt' in 'field list'

但解决方案对我不起作用! 为什么? 这是我的代码:

 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
  });

错误是:

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'

1 个答案:

答案 0 :(得分:3)

不应将teams.sort do |a, b| result = [a.points, a.goals_dif, a.goals] <=> [b.points, b.goals_dif, b.goals] result.zero? ? a_beats_b(a, b) : result end 作为{ timestamps: false }调用的附加参数传递,而应使用相应的属性扩展现有(第三个):

Sequelize.define

...正如the docs中所述。