«

sequelize时间格式化

emer 发布于 2020-9-18 10:03   1839 次阅读     


初始化Sequelize的时候传入dialectOptions参数


let sequelize = new Sequelize(
    config.MYSQL_OPTIONS.database,
    config.MYSQL_OPTIONS.user,
    config.MYSQL_OPTIONS.password,
    {
        host: config.MYSQL_OPTIONS.host,
        port: config.MYSQL_OPTIONS.port,
        dialect: 'mysql',
        dialectOptions: {
            dateStrings: true,
            typeCast: true
        },
        pool: {
            max: 5,
            min: 0,
            acquire: 30000,
            idle: 10000
        },
        timezone: '+08:00' //改为标准时区
    }
);