split per app

This commit is contained in:
2020-08-16 11:48:06 +02:00
parent d3a19c953a
commit c5be16963d
12 changed files with 126 additions and 14 deletions

9
lib/db/app.js Normal file
View File

@ -0,0 +1,9 @@
'use strict';
module.exports = (get_db) => ({
get_all () {
const knex = get_db ();
return knex ('app')
.select ();
}
});

View File

@ -18,9 +18,11 @@ async function init (use_fake_seed) {
await db.seed.run ({ specific: 'fake.js' });
}
function get_all () {
return db ('log')
.select ();
function get_db () {
return db;
}
module.exports = { init, get_all };
const log = require ('./log') (get_db);
const app = require ('./app') (get_db);
module.exports = { init, log, app };

15
lib/db/log.js Normal file
View File

@ -0,0 +1,15 @@
'use strict';
module.exports = (get_db) => ({
get_all (app_id) {
const knex = get_db ();
return knex.select (
'id',
'message',
'data',
'timestamp'
)
.from ('log')
.where ({ app_id });
}
});