add ignoreMissing flag to becca's getNotes()

This commit is contained in:
zadam 2021-07-22 21:23:01 +02:00
parent f9cfd134b7
commit 7261ab69bc
3 changed files with 7 additions and 3 deletions

View File

@ -90,7 +90,7 @@
"jsdoc": "3.6.7",
"lorem-ipsum": "2.0.3",
"rcedit": "3.0.1",
"webpack": "5.45.1",
"webpack": "5.46.0",
"webpack-cli": "4.7.2"
},
"optionalDependencies": {

View File

@ -55,13 +55,17 @@ class Becca {
return this.notes[noteId];
}
getNotes(noteIds) {
getNotes(noteIds, ignoreMissing = false) {
const filteredNotes = [];
for (const noteId of noteIds) {
const note = this.notes[noteId];
if (!note) {
if (ignoreMissing) {
continue;
}
throw new Error(`Note '${noteId}' was not found in becca.`);
}

View File

@ -120,7 +120,7 @@ function getEditedNotesOnDate(req) {
ORDER BY isDeleted
LIMIT 50`, {date: req.params.date + '%'});
const notes = becca.getNotes(noteIds);
const notes = becca.getNotes(noteIds, true);
for (const note of notes) {
const notePath = note.isDeleted ? null : beccaService.getNotePath(note.noteId);