2019-05-22 11:28:57 +00:00
|
|
|
"use strict";
|
|
|
|
|
2019-05-22 17:04:46 +00:00
|
|
|
import fs from 'fs';
|
|
|
|
import Database from 'better-sqlite3';
|
2019-05-22 11:28:57 +00:00
|
|
|
|
2019-05-22 17:04:46 +00:00
|
|
|
var db = null;
|
2019-05-22 11:28:57 +00:00
|
|
|
|
2019-05-22 17:04:46 +00:00
|
|
|
async function init(filename, options) {
|
|
|
|
db = new Database(filename, options);
|
|
|
|
db.exec(await fs.promises.readFile("../db_template.sql", "utf8"));
|
2019-05-22 11:28:57 +00:00
|
|
|
}
|
|
|
|
|
2019-05-22 17:04:46 +00:00
|
|
|
function get_instance() {
|
|
|
|
return db;
|
2019-05-22 11:28:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-22 17:04:46 +00:00
|
|
|
export { init, get_instance };
|