@@ -11,42 +11,43 @@ import { config } from './config';
1111const database = config . getItem ( 'db.database' , 'lin-cms' ) ;
1212
1313/**
14- * 数据库类型,默认mysql
14+ * 数据库用户名,默认root
1515 */
16- const type = config . getItem ( 'db.type ' , 'mysql ' ) ;
16+ const username = config . getItem ( 'db.username ' , 'root ' ) ;
1717
1818/**
19- * 数据库host,默认localhost
19+ * 数据库密码,默认123456
2020 */
21- const host = config . getItem ( 'db.host ' , 'localhost ' ) ;
21+ const password = config . getItem ( 'db.password ' , '123456 ' ) ;
2222
2323/**
24- * 数据库端口,默认3306
24+ * 其它数据库配置项
2525 */
26- const port = config . getItem ( 'db.port ' , 3306 ) ;
26+ const options = config . getItem ( 'db' , { } ) ;
2727
2828/**
29- * 数据库用户名,默认root
29+ * 全局的 Sequelize 实例
3030 */
31- const username = config . getItem ( 'db.username' , 'root' ) ;
31+ export const db = new Sequelize ( database , username , password , {
32+ ...options
33+ } ) ;
3234
3335/**
34- * 数据库密码,默认123456
36+ * 数据库类型,默认mysql, dialect
3537 */
36- const password = config . getItem ( 'db.password ' , '123456 ' ) ;
38+ // const type = config.getItem('db.type ', 'mysql ');
3739
3840/**
39- * 是否输出sequelize日志,默认 true
41+ * 数据库host,默认localhost
4042 */
41- const logging = config . getItem ( 'db.logging ' , true ) ;
43+ // const host = config.getItem('db.host ', 'localhost' );
4244
4345/**
44- * 全局的 Sequelize 实例
46+ * 数据库端口,默认3306
4547 */
46- export const db = new Sequelize ( database , username , password , {
47- host : host ,
48- port : port ,
49- dialect : type ,
50- logging : logging ,
51- timezone : '+08:00'
52- } ) ;
48+ // const port = config.getItem('db.port', 3306);
49+
50+ /**
51+ * 是否输出sequelize日志,默认 true
52+ */
53+ // const logging = config.getItem('db.logging', true);
0 commit comments