AppReports/lib/db/index.js

27 lines
528 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_all () {
return db ('log')
.select ();
}
module.exports = { init, get_all };