Bugfix: Reference db_template currectly when initialising the db connection

This commit is contained in:
Starbeamrainbowlabs 2019-07-10 14:13:47 +01:00
parent bd08aae1da
commit 08a4ebe9f1
1 changed files with 3 additions and 2 deletions

View File

@ -1,13 +1,14 @@
"use strict";
import fs from 'fs';
import path from 'path';
import Database from 'better-sqlite3';
var db = null;
function init({ settings: { database: { filename, options } } }) {
function init({ root_dir, settings: { database: { filename, options } } }) {
db = new Database(filename, options);
db.exec(fs.readFileSync("../db_template.sql", "utf8"));
db.exec(fs.readFileSync(path.join(root_dir, "./db_template.sql"), "utf8"));
return db;
}