delete now works with multi-select

This commit is contained in:
azivner
2018-01-14 21:39:21 -05:00
parent 45a92313d5
commit d30a57d388
7 changed files with 31 additions and 30 deletions
+7 -7
View File
@@ -121,15 +121,15 @@ async function runAllChecks() {
await runCheck(`
SELECT
child.note_id
child.note_tree_id
FROM
notes_tree
JOIN notes AS child ON child.note_id = notes_tree.note_id
JOIN notes AS parent ON notes_tree.parent_note_id = parent.note_id
notes_tree AS child
WHERE
parent.is_deleted = 1
AND child.is_deleted = 0`,
"Parent note is deleted but child note is not for these child note IDs", errorList);
child.is_deleted = 0
AND child.parent_note_id != 'root'
AND (SELECT COUNT(*) FROM notes_tree AS parent WHERE parent.note_id = child.parent_note_id
AND parent.is_deleted = 0) = 0`,
"All parent note trees are deleted but child note tree is not for these child note tree IDs", errorList);
// we do extra JOIN to eliminate orphan notes without note tree (which are reported separately)
await runCheck(`
+6
View File
@@ -243,6 +243,12 @@ async function updateNote(noteId, newNote, dataKey, sourceId) {
}
async function deleteNote(noteTreeId, sourceId) {
const noteTree = await sql.getFirstOrNull("SELECT * FROM notes_tree WHERE note_tree_id = ?", [noteTreeId]);
if (!noteTree || noteTree.is_deleted === 1) {
return;
}
const now = utils.nowDate();
await sql.execute("UPDATE notes_tree SET is_deleted = 1, date_modified = ? WHERE note_tree_id = ?", [now, noteTreeId]);