-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
65 lines (54 loc) · 1.71 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// 初始化数据库
var mysql = require('mysql');
var config = require('./config');
var dbConfig = config.db;
var connection = mysql.createConnection(dbConfig);
connection.connect();
connection.query('CREATE DATABASE ' + dbConfig.database, (err, rows, fields) => {
console.log('create');
if (err) throw err;
// var p1 = new Promise((resolve, reject) => {
// console.log('p1');
// connection.query('\
// CREATE TABLE `' + dbConfig.database + '`.`' + 'friends' + '` ( \
// `id` VARCHAR(40) NOT NULL, \
// `name` VARCHAR(20) NOT NULL, \
// `sex` CHAR(60), \
// PRIMARY KEY (`id`), \
// UNIQUE INDEX `id_UNIQUE` (`id` ASC) \
// )', (err, rows, fields) => {
// if (err) throw err;
// resolve();
// });
// });
// var p2 = new Promise((resolve, reject) => {
// connection.query('\
// CREATE TABLE `' + dbConfig.database + '`.`' + 'groups' + '` ( \
// `id` VARCHAR(40) NOT NULL, \
// `name` VARCHAR(20) NOT NULL, \
// `count` INT UNSIGNED NOT NULL, \
// PRIMARY KEY (`id`), \
// UNIQUE INDEX `id_UNIQUE` (`id` ASC) \
// )', (err, rows, fields) => {
// if (err) throw err;
// resolve();
// });
// });
// var p3 = new Promise((resolve, reject) => {
// console.log('p3');
// connection.query('\
// CREATE TABLE `' + dbConfig.database + '`.`' + 'watch' + '` ( \
// `id` VARCHAR(40) NOT NULL, \
// `name` VARCHAR(20) NOT NULL, \
// PRIMARY KEY (`id`), \
// UNIQUE INDEX `id_UNIQUE` (`id` ASC) \
// )', (err, rows, fields) => {
// if (err) throw err;
// resolve();
// });
// });
// Promise.all([p1, p2, p3]).then((result) => {
// console.log('Success: Database Created!')
// connection.end();
// })
});