mirror of
https://github.com/zadam/trilium.git
synced 2025-10-27 16:26:31 +01:00
ETAPI delete/patch, refactoring
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user