Sequelize为createdAt字段返回null

时间:2019-09-18 12:32:20

标签: postgresql sequelize.js timestamp-with-timezone

我在Potgres 10.5上有一个数据库, 我正在使用sequelize连接到它,在每个查询中,尽管表中有时间戳,在每个带有时间戳的时间戳的createdAt字段始终返回null

我不知道问题出在哪里

const sequelize = new Sequelize(process.env.DB_URL, {
  dialect: 'postgres',
  logging: false
});```

//Model
const Metric = sequelize.define(
    'metrics',
    {
      _id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true
      },
      title: {
        type: DataTypes.STRING,
      },
)

//query
const result = await Metric.findAll()

//result
[
   {
    _id: 1
    title: "test"
    createdAt: null
   }
]

//data in the table
_id   title    createdAt
"1"   "test"   "2019-09-18 13:16:58.14+2"

0 个答案:

没有答案