mirror of
https://github.com/TriliumNext/Notes.git
synced 2026-05-05 11:49:12 -05:00
34 lines
964 B
JavaScript
34 lines
964 B
JavaScript
"use strict";
|
|
|
|
const NoteSet = require('../note_set');
|
|
const noteCache = require('../../note_cache/note_cache');
|
|
|
|
class NoteContentFulltextExp {
|
|
constructor(tokens) {
|
|
this.tokens = tokens;
|
|
}
|
|
|
|
async execute(noteSet) {
|
|
const resultNoteSet = new NoteSet();
|
|
const wheres = this.tokens.map(token => "note_contents.content LIKE " + utils.prepareSqlForLike('%', token, '%'));
|
|
|
|
const noteIds = await sql.getColumn(`
|
|
SELECT notes.noteId
|
|
FROM notes
|
|
JOIN note_contents ON notes.noteId = note_contents.noteId
|
|
WHERE isDeleted = 0 AND isProtected = 0 AND ${wheres.join(' AND ')}`);
|
|
|
|
const results = [];
|
|
|
|
for (const noteId of noteIds) {
|
|
if (noteSet.hasNoteId(noteId) && noteId in noteCache.notes) {
|
|
resultNoteSet.add(noteCache.notes[noteId]);
|
|
}
|
|
}
|
|
|
|
return results;
|
|
}
|
|
}
|
|
|
|
module.exports = NoteContentFulltextExp;
|