Skip to content

Commit

Permalink
refactor 重构数据库配置
Browse files Browse the repository at this point in the history
  • Loading branch information
tumobi committed Feb 9, 2018
1 parent 4143f00 commit 1c86330
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/common/config/adapter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const fileCache = require('think-cache-file');
const mysql = require('think-model-mysql');
const {Console, File, DateFile} = require('think-logger3');
const path = require('path');
const database = require('./database.js');

const isDev = think.env === 'development';

/**
Expand Down Expand Up @@ -32,17 +33,7 @@ exports.model = {
logSql: isDev,
logger: msg => think.logger.info(msg)
},
mysql: {
handle: mysql,
database: 'nideshop',
prefix: 'nideshop_',
encoding: 'utf8mb4',
host: '127.0.0.1',
port: '3306',
user: 'root',
password: 'root',
dateStrings: true
}
mysql: database
};

/**
Expand Down
13 changes: 13 additions & 0 deletions src/common/config/database.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const mysql = require('think-model-mysql');

module.exports = {
handle: mysql,
database: 'nideshop',
prefix: 'nideshop_',
encoding: 'utf8mb4',
host: '127.0.0.1',
port: '3306',
user: 'root',
password: 'root',
dateStrings: true
};

0 comments on commit 1c86330

Please sign in to comment.