2019-05-22 11:28:57 +00:00
|
|
|
"use strict";
|
|
|
|
|
2019-05-22 17:04:46 +00:00
|
|
|
import fs from 'fs';
|
2019-07-10 13:13:47 +00:00
|
|
|
import path from 'path';
|
2019-05-22 17:04:46 +00:00
|
|
|
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-07-10 13:13:47 +00:00
|
|
|
function init({ root_dir, settings: { database: { filename, options } } }) {
|
2019-05-22 17:04:46 +00:00
|
|
|
db = new Database(filename, options);
|
2019-07-10 13:13:47 +00:00
|
|
|
db.exec(fs.readFileSync(path.join(root_dir, "./db_template.sql"), "utf8"));
|
2019-05-22 17:04:46 +00:00
|
|
|
return db;
|
2019-05-22 11:28:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-23 19:10:06 +00:00
|
|
|
export default init;
|