mirror of
https://github.com/zadam/trilium.git
synced 2025-11-12 16:25:51 +01:00
To prevent search lag when there are a large number of notes
This commit is contained in:
@@ -8,6 +8,7 @@ import cls from "../../services/cls.js";
|
||||
import becca from "../../becca/becca.js";
|
||||
import type { Request } from "express";
|
||||
import ValidationError from "../../errors/validation_error.js";
|
||||
import sql from "../../services/sql.js";
|
||||
|
||||
function getAutocomplete(req: Request) {
|
||||
if (typeof req.query.query !== "string") {
|
||||
@@ -79,6 +80,15 @@ function getRecentNotes(activeNoteId: string) {
|
||||
});
|
||||
}
|
||||
|
||||
// Get the total number of notes
|
||||
function getNotesCount(req: Request) {
|
||||
const notesCount = sql.getRow(
|
||||
`SELECT COUNT(*) AS count FROM notes WHERE isDeleted = 0;`,
|
||||
) as { count: number };
|
||||
return notesCount.count;
|
||||
}
|
||||
|
||||
export default {
|
||||
getAutocomplete
|
||||
getAutocomplete,
|
||||
getNotesCount
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user