mirror of
https://github.com/zadam/trilium.git
synced 2024-11-11 09:46:25 +08:00
23 lines
No EOL
582 B
JavaScript
23 lines
No EOL
582 B
JavaScript
"use strict";
|
|
|
|
const express = require('express');
|
|
const router = express.Router();
|
|
const sql = require('../../services/sql');
|
|
|
|
router.get('', async (req, res, next) => {
|
|
await deleteOld();
|
|
|
|
const result = await sql.getResults("SELECT * FROM event_log ORDER BY date_added DESC");
|
|
|
|
res.send(result);
|
|
});
|
|
|
|
async function deleteOld() {
|
|
const cutoffId = await sql.getSingleValue("SELECT id FROM event_log ORDER BY id DESC LIMIT 1000, 1");
|
|
|
|
if (cutoffId) {
|
|
await sql.execute("DELETE FROM event_log WHERE id < ?", [cutoffId]);
|
|
}
|
|
}
|
|
|
|
module.exports = router; |