trilium/src/routes/api/similar_notes.js
2020-09-10 21:01:46 +02:00

24 lines
536 B
JavaScript

"use strict";
const noteCacheService = require('../../services/note_cache/note_cache_service');
const repository = require('../../services/repository');
async function getSimilarNotes(req) {
const noteId = req.params.noteId;
const note = repository.getNote(noteId);
if (!note) {
return [404, `Note ${noteId} not found.`];
}
const results = await noteCacheService.findSimilarNotes(noteId);
return results
.filter(note => note.noteId !== noteId);
}
module.exports = {
getSimilarNotes
};