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