aboutsummaryrefslogtreecommitdiff
path: root/update.js
diff options
context:
space:
mode:
authorJoel Kronqvist <work.joelkronqvist@gmail.com>2022-10-17 10:59:43 +0300
committerJoel Kronqvist <work.joelkronqvist@gmail.com>2022-10-17 10:59:43 +0300
commit22a4830bb09cbecf6c2e8e52601a4e821bddbe8e (patch)
tree43db3f30041f63cbc98fac9da331e6e256f7f870 /update.js
parentc38a4cfc0d9c8dbd91c07b03a393a0dd89721b5a (diff)
downloadLYLLRuoka-22a4830bb09cbecf6c2e8e52601a4e821bddbe8e.tar.gz
LYLLRuoka-22a4830bb09cbecf6c2e8e52601a4e821bddbe8e.zip
Imroved README.md, modified server to update on start
Also minor changes to setup.sh and update.js. In update.js the updation function was changed to take a database connection (as in database.js) instead of a string with the credentials to the DB.
Diffstat (limited to 'update.js')
-rw-r--r--update.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/update.js b/update.js
index c66a97b..c946304 100644
--- a/update.js
+++ b/update.js
@@ -1,17 +1,15 @@
-const database = require("./database.js");
const openFile = require("./Functions/open.js").file;
const parseClasses = require("./parseClasses.js").classes;
const parse = require("./dbparse.js");
// Run this if you want to build the database from text files
-async function buildDB(dbcredentials, shiftPath, ...classfiles)
+async function buildDB(dbconnection, shiftPath, ...classfiles)
{
- const DB = new database.Database(JSON.parse(dbcredentials));
let shiftCont = await openFile(shiftPath);
shiftCont = shiftCont.toString("utf-8").replaceAll("\r", ""); // \r because of the \r\n newline on windows which may create problems
- await parseClasses(DB, ...classfiles),
- await parse.build(shiftCont, DB)
+ await parseClasses(dbconnection, ...classfiles),
+ await parse.build(shiftCont, dbconnection)
return 0;
}
@@ -19,6 +17,8 @@ exports.update = buildDB;
// Example call:
/*
const openFile = require("./Functions/open.js").file;
+const database = require("./database.js");
const dbcredentials = await openFile("../dblogin.txt");
+const DB = new database.Database(JSON.parse(dbcredentials));
await updateDB.update(dbcredentials, "./shifts.txt", "./Kurssitarjottimet/2016Classes.txt", "./Kurssitarjottimet/NewClasses.txt");
*/