Timo Hocker
04707545f1
Some checks reported errors
continuous-integration/drone/push Build was killed
31 lines
785 B
JavaScript
31 lines
785 B
JavaScript
/*
|
|
* Copyright (C) Sapphirecode - All Rights Reserved
|
|
* This file is part of appreports which is released under GPL-3.0-or-later.
|
|
* See file 'LICENSE' for full license details.
|
|
* Created by Timo Hocker <timo@scode.ovh>, August 2020
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
module.exports = (get_db) => ({
|
|
get_all (app_id, limit = 100, offset = 0) {
|
|
const knex = get_db ();
|
|
return knex.select (
|
|
'id',
|
|
'message',
|
|
'data',
|
|
'timestamp'
|
|
)
|
|
.from ('log')
|
|
.where ({ app_id })
|
|
.orderBy ('timestamp', 'desc')
|
|
.limit (Math.min (limit, 10000))
|
|
.offset (offset);
|
|
},
|
|
insert (app_id, message, data = '{}', timestamp = (new Date)) {
|
|
const knex = get_db ();
|
|
return knex ('log')
|
|
.insert ({ message, data, timestamp, app_id });
|
|
}
|
|
});
|