diff options
| author | Mhykol <mchaeldonald62@pm.me> | 2026-08-28 15:30:45 -0400 |
|---|---|---|
| committer | Mhykol <mchaeldonald62@pm.me> | 2026-08-28 15:30:45 -0400 |
| commit | b632faab8f7e50d65aa6cc7dc4798d7cf3a18a5a (patch) | |
| tree | 314aa045af331f96886b3a3378c4b998007ce46c | |
| parent | 4724a375baeb84ac1c98b6166681a743b0fca295 (diff) | |
Tracking database.js
| -rw-r--r-- | src/database.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/database.js b/src/database.js new file mode 100644 index 0000000..aeea0f0 --- /dev/null +++ b/src/database.js @@ -0,0 +1,38 @@ +const mysql = require('mysql2') +const logger = require('./logger')() +require('dotenv').config() + +// Authenticates with SQL server and send query +class Database { + constructor(x) { + this.host = x.host + this.user = x.username + this.password = x.password + this.database = x.database + } + + CreatePool() { + return mysql.createPool({ + host: this.host, + user: this.user, + password: this.password, + database: this.database + }).promise() + } + + Query(x) {return this.pool.query(x)} +} + +module.exports = (x) => { + const database = new Database(x) + const pools = [] + const createPool = () => { + pools.push(database.CreatePool()) + } + + return { + pools: pools, + createPool: createPool + } +} + |
