配置文件
development: { username: process.env.LOCAL_USERNAME, password: process.env.LOCAL_PASSWORD, database: process.env.LOCAL_DATABASE, //数据库ip地址 host: '127.0.0.1', dialect: 'mssql', dialectOptions: { //数据库实例名称,没有则不用设置 instanceName: 'SQLEXPRESS' }, //定义表名的前缀,不设置此属性,则没有前缀 define: { schema: "core" }, port: '1433', }
实例化数据库
var config = require('../config'); const Sequelize = require('sequelize'); const sequelize = new Sequelize(config.database, config.username, config.password, { host: config.host, dialect: 'mssql', dialectOptions: { instanceName: 'SQLEXPRESS' }, // define: { // schema: "core" // }, pool: { max: 5, min: 0, idle: 10000 }, timezone: '+08:00' //东八时区,不设置时区,时间不正确 }); module.exports = sequelize