egg 查询数据时间戳转换
粉丝福利 : 关注VUE中文社区公众号,回复视频领取粉丝福利
需要借助moment 在 get的时候进行转 换
const EventType = app.model.define('custom_event_type', {
id: { type: INTEGER, primaryKey: true, autoIncrement: true },
type: {
type: STRING,
unique: true,
allowNull: false,
},
remark: STRING,
project_id: INTEGER,
created_at: {
type: DATE,
get() {
return moment(this.getDataValue('created_at')).format('YYYY-MM-DD HH:mm:ss')
},
},
updated_at: {
type: DATE,
get() {
return moment(this.getDataValue('updated_at')).format('YYYY-MM-DD HH:mm:ss')
},
},
});