29 lines
586 B
JavaScript
29 lines
586 B
JavaScript
'use strict';
|
|
|
|
const knex = require ('knex');
|
|
|
|
let db = null;
|
|
|
|
async function init (use_fake_seed) {
|
|
db = knex ({
|
|
client: 'sqlite',
|
|
connection: { filename: 'db.sqlite' },
|
|
migrations: { directory: 'migrations' },
|
|
seeds: { directory: 'seeds' },
|
|
useNullAsDefault: true
|
|
});
|
|
|
|
await db.migrate.latest ();
|
|
if (use_fake_seed)
|
|
await db.seed.run ({ specific: 'fake.js' });
|
|
}
|
|
|
|
function get_db () {
|
|
return db;
|
|
}
|
|
|
|
const log = require ('./log') (get_db);
|
|
const app = require ('./app') (get_db);
|
|
|
|
module.exports = { init, log, app };
|