From e6626356d90fcc58db1dbfad35211c0b3a103aa7 Mon Sep 17 00:00:00 2001 From: LarsVomMars Date: Wed, 7 Oct 2020 23:42:34 +0200 Subject: User profile boilerplate --- db.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'db.js') diff --git a/db.js b/db.js index 16f2970..49caabd 100644 --- a/db.js +++ b/db.js @@ -40,6 +40,7 @@ class DB { "INSERT INTO class (name) VALUES ('TGM13.1'), ('TGM13.2'), ('TGTM13.1'), ('TGI13.1'), ('TGI13.2'), ('teacher')" ); + // User polls fs.readFile(__dirname + "/poll.txt", "utf8", (err, data) => { if (err) throw err; @@ -53,6 +54,7 @@ class DB { }); }); + // Motto votes fs.readFile(__dirname + "/mottos.txt", "utf8", (err, data) => { if (err) throw err; @@ -64,6 +66,15 @@ class DB { }); }); + fs.readFile(__dirname + "/profile.txt", "utf8", (err, data) => { + if (err) throw err; + + const questions = data.split("\n"); + questions.forEach((question) => { + if (question) this.query("INSERT INTO profile_questions (question) VALUE (?)", [question]); + }); + }); + const classes = data.split("--"); const userPasswords = {}; console.log("Generating users"); -- cgit v1.2.3