Skip to content

Commit 7c07a46

Browse files
committed
'db配置'
1 parent 79df8d2 commit 7c07a46

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

config/server.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
import ip from 'ip';
2-
import options from '';
1+
export default {
2+
db: process.env.NODE_ENV === 'development' ? 'localhost' : '',
3+
4+
}
File renamed without changes.

utils/db.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import mysql from 'mysql'
2+
3+
const pool = mysql.createPool({
4+
host: '',
5+
user: 'root',
6+
password: '',
7+
database: 'qq'
8+
})
9+
10+
export default (sql, values) => {
11+
return Promise((resolve, reject) => {
12+
pool.getConnection((err, connection) => {
13+
if (err) {
14+
reject(err)
15+
} else {
16+
connection.query(sql, values, (err, rows) => {
17+
if (err) {
18+
reject(err)
19+
} else {
20+
resolve(rows)
21+
}
22+
})
23+
}
24+
connection.release()
25+
})
26+
})
27+
}

utils/index.js

Whitespace-only changes.

0 commit comments

Comments
 (0)