blob: 78e8a1fa45d9aa8dfdbdb48a83b19673aa75f86b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
const mysql = require('mysql2')
const logger = require('./logger')()
require('dotenv').config()
// Authenticates with SQL server and send query
class Database {
constructor(x) {
this.pool = mysql.createPool({
host: process.env.MYSQL_HOST,
user: process.env.MYSQL_USER,
password: process.env.MYSQL_PASSWORD,
database: x
}).promise()
}
async Query(x) {try {return await this.pool.query(x)} catch (err) {logger.Error(err)}}
}
module.exports = (x) => {return new Database(x)}
|