ETAPI delete/patch, refactoring

This commit is contained in:
zadam
2022-01-07 19:33:59 +01:00
parent 82b2871a08
commit 9ee1c9f3da
36 changed files with 1304 additions and 11678 deletions

View File

@@ -105,6 +105,10 @@ function createNewNote(params) {
if (!params.title || params.title.trim().length === 0) {
throw new Error(`Note title must not be empty`);
}
if (params.content === null || params.content === undefined) {
throw new Error(`Note content must be set`);
}
return sql.transactional(() => {
const note = new Note({
@@ -519,7 +523,7 @@ function updateNote(noteId, noteUpdates) {
/**
* @param {Branch} branch
* @param {string} deleteId
* @param {string|null} deleteId
* @param {TaskContext} taskContext
*
* @return {boolean} - true if note has been deleted, false otherwise
@@ -569,6 +573,17 @@ function deleteBranch(branch, deleteId, taskContext) {
}
}
/**
* @param {Note} note
* @param {string|null} deleteId
* @param {TaskContext} taskContext
*/
function deleteNote(note, deleteId, taskContext) {
for (const branch of note.getParentBranches()) {
deleteBranch(branch, deleteId, taskContext);
}
}
/**
* @param {string} noteId
* @param {TaskContext} taskContext
@@ -914,6 +929,7 @@ module.exports = {
createNewNoteWithTarget,
updateNote,
deleteBranch,
deleteNote,
undeleteNote,
protectNoteRecursively,
scanForLinks,