aboutsummaryrefslogtreecommitdiff
path: root/db.js
diff options
context:
space:
mode:
authorMarvin Borner2021-01-27 23:28:55 +0100
committerMarvin Borner2021-01-27 23:28:55 +0100
commit3045ccac64a1595a7ed89415cd0521e387bfa2c7 (patch)
tree40989f641afead3fee265715fb3be950323c2456 /db.js
parenta032120bf8fe1e905082ade0dd14fd2198a4574b (diff)
That's dump (pun intended)
Diffstat (limited to 'db.js')
-rw-r--r--db.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/db.js b/db.js
index 2735257..af18a47 100644
--- a/db.js
+++ b/db.js
@@ -185,7 +185,10 @@ class DB {
const [q, a] = question.split(" - ");
const { insertId } = await this.query("INSERT INTO question_questions (question) VALUE (?)", [q]);
for (const answer of a.split(",")) {
- await this.query("INSERT INTO question_options (answer_option, question_id) VALUE (?,?)", [answer, insertId]);
+ await this.query("INSERT INTO question_options (answer_option, question_id) VALUE (?,?)", [
+ answer,
+ insertId,
+ ]);
}
} catch (e) {
console.error(e);
@@ -218,6 +221,13 @@ class DB {
console.log(`New password for ${uid}: ${pwd}`);
}
+ async dump() {
+ const users = await this.query(
+ "SELECT u.id, u.username, u.name, u.middlename, u.surname, c.name class, t.name type FROM users u INNER JOIN class c ON u.class_id = c.id INNER JOIN types t ON u.type_id = t.id WHERE t.name = 'pupil'",
+ );
+ return { users };
+ }
+
async query(query, params) {
const conn = await this.connect();
try {