aboutsummaryrefslogtreecommitdiff
path: root/database.js
diff options
context:
space:
mode:
authorJoelHMikael <joel.h.kronqvist@gmail.com>2022-01-07 10:58:02 +0200
committerJoelHMikael <joel.h.kronqvist@gmail.com>2022-01-07 10:58:02 +0200
commit4e5fe4711fe46a6af740aadbf23bde86bb5acf69 (patch)
treea6c11bbdda6d6f42848961b19c365db0c91cb4b8 /database.js
parente7b4d365f287f173c8cc0b5a4d965c3a0579c2e0 (diff)
downloadLYLLRuoka-4e5fe4711fe46a6af740aadbf23bde86bb5acf69.tar.gz
LYLLRuoka-4e5fe4711fe46a6af740aadbf23bde86bb5acf69.zip
Added the DB class & instructions to set up DB
Diffstat (limited to 'database.js')
-rw-r--r--database.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/database.js b/database.js
new file mode 100644
index 0000000..3a2822a
--- /dev/null
+++ b/database.js
@@ -0,0 +1,37 @@
+class Database
+{
+ constructor(credentials, log)
+ {
+ this.connection = mysql.createConnection(credentials);
+ this.log = log;
+ }
+ query(q)
+ {
+ return new Promise((resolve, reject), () =>
+ {
+ this.connection.query(q, (err, res, fields) =>
+ {
+ if (err)
+ {
+ this.log(err);
+ reject(err);
+ }
+ resolve(res);
+ });
+ });
+ }
+ close()
+ {
+ this.connection.end(err =>
+ {
+ if (err)
+ {
+ this.log(err);
+ reject(err);
+ }
+ resolve();
+ });
+ }
+}
+
+exports.Database = Database;