diff options
author | Marvin Borner | 2021-01-27 23:28:55 +0100 |
---|---|---|
committer | Marvin Borner | 2021-01-27 23:28:55 +0100 |
commit | 3045ccac64a1595a7ed89415cd0521e387bfa2c7 (patch) | |
tree | 40989f641afead3fee265715fb3be950323c2456 /db.js | |
parent | a032120bf8fe1e905082ade0dd14fd2198a4574b (diff) |
That's dump (pun intended)
Diffstat (limited to 'db.js')
-rw-r--r-- | db.js | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -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 { |