-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.js
More file actions
30 lines (28 loc) · 773 Bytes
/
database.js
File metadata and controls
30 lines (28 loc) · 773 Bytes
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
const mysql = require('mysql');
const util = require('util');
let database = {
configuration:{
host: 'localhost',
user: 'root',
password: 'David2005_',
database: 'presents',
multipleStatements: true
},
connected:false,
mysqlConnection:null,
query:null,
connect() {
if ( this.connected == false){
this.connected = true;
this.mysqlConnection = mysql.createConnection(this.configuration);
this.query = util.promisify(this.mysqlConnection.query).bind(this.mysqlConnection);
}
},
disConnect () {
if ( this.connected == true){
this.connected = false;
this.mysqlConnection.end();
}
}
}
module.exports=database