init simple appreports
This commit is contained in:
26
lib/db/index.js
Normal file
26
lib/db/index.js
Normal file
@ -0,0 +1,26 @@
|
||||
'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 };
|
Reference in New Issue
Block a user