mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
23 lines
535 B
JavaScript
23 lines
535 B
JavaScript
"use strict";
|
|
|
|
const sql = require('../../services/sql');
|
|
|
|
async function getEventLog() {
|
|
await deleteOld();
|
|
|
|
return await sql.getRows("SELECT * FROM event_log ORDER BY dateAdded DESC");
|
|
}
|
|
|
|
async function deleteOld() {
|
|
const cutoffId = await sql.getValue("SELECT id FROM event_log ORDER BY id DESC LIMIT 1000, 1");
|
|
|
|
if (cutoffId) {
|
|
await sql.doInTransaction(async () => {
|
|
await sql.execute("DELETE FROM event_log WHERE id < ?", [cutoffId]);
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
getEventLog
|
|
}; |