From 3045ccac64a1595a7ed89415cd0521e387bfa2c7 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 27 Jan 2021 23:28:55 +0100 Subject: That's dump (pun intended) --- db.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'db.js') 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 { -- cgit v1.2.3