mirror of
https://github.com/zadam/trilium.git
synced 2024-12-26 09:12:08 +08:00
bd2a5f6d82
added assert methods to note tree
26 lines
No EOL
705 B
JavaScript
26 lines
No EOL
705 B
JavaScript
"use strict";
|
|
|
|
const express = require('express');
|
|
const router = express.Router();
|
|
const sql = require('../../services/sql');
|
|
const auth = require('../../services/auth');
|
|
|
|
router.get('', auth.checkApiAuth, async (req, res, next) => {
|
|
await deleteOld();
|
|
|
|
const result = await sql.getAll("SELECT * FROM event_log ORDER BY date_added DESC");
|
|
|
|
res.send(result);
|
|
});
|
|
|
|
async function deleteOld() {
|
|
const cutoffId = await sql.getFirstValue("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 = router; |