bugfix for sql setup
parent
f21c44abd4
commit
989ea77e84
14
db.js
14
db.js
|
@ -1,6 +1,6 @@
|
||||||
const sqlite3 = require("sqlite3");
|
const sqlite3 = require("sqlite3");
|
||||||
const fs = require('fs');
|
const fs = require("fs");
|
||||||
const db = new sqlite3.Database('vybe.db');
|
const db = new sqlite3.Database("vybe.db");
|
||||||
|
|
||||||
db.query = function (sql, params) {
|
db.query = function (sql, params) {
|
||||||
var that = this;
|
var that = this;
|
||||||
|
@ -13,10 +13,14 @@ db.query = function (sql, params) {
|
||||||
};
|
};
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
if (!fs.existsSync('vybe.db')) {
|
if (!fs.existsSync("vybe.db")) {
|
||||||
console.log(fs.readFileSync('db/1-init.sql').toString().split(';'))
|
for (let sql of fs
|
||||||
for(let sql of fs.readFileSync('db/1-init.sql').toString().split(';'))
|
.readFileSync("db/1-init.sql")
|
||||||
|
.toString()
|
||||||
|
.split(";")
|
||||||
|
.filter((x) => x)) {
|
||||||
await db.query(sql);
|
await db.query(sql);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue