mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 10:55:55 +01:00
added foreign keys to relations to guarantee data consistency
This commit is contained in:
@@ -132,7 +132,7 @@ const noteTree = (function() {
|
||||
|
||||
delete note.note_title; // this should not be used. Use noteIdToTitle instead
|
||||
|
||||
setParentChildRelation(note.note_tree_id, note.note_pid, note.note_id);
|
||||
setParentChildRelation(note.note_tree_id, note.parent_note_id, note.note_id);
|
||||
}
|
||||
|
||||
return prepareNoteTreeInner('root');
|
||||
@@ -171,7 +171,7 @@ const noteTree = (function() {
|
||||
|
||||
const node = {
|
||||
note_id: noteTree.note_id,
|
||||
note_pid: noteTree.note_pid,
|
||||
parent_note_id: noteTree.parent_note_id,
|
||||
note_tree_id: noteTree.note_tree_id,
|
||||
is_protected: noteTree.is_protected,
|
||||
prefix: noteTree.prefix,
|
||||
@@ -207,7 +207,7 @@ const noteTree = (function() {
|
||||
//console.log(now(), "Run path: ", runPath);
|
||||
|
||||
for (const childNoteId of runPath) {
|
||||
const node = getNodesByNoteId(childNoteId).find(node => node.data.note_pid === parentNoteId);
|
||||
const node = getNodesByNoteId(childNoteId).find(node => node.data.parent_note_id === parentNoteId);
|
||||
|
||||
if (childNoteId === noteId) {
|
||||
await node.setActive();
|
||||
@@ -334,6 +334,10 @@ const noteTree = (function() {
|
||||
while (cur !== 'root') {
|
||||
path.push(cur);
|
||||
|
||||
if (!childToParents[cur]) {
|
||||
throwError("Can't find parents for " + cur);
|
||||
}
|
||||
|
||||
cur = childToParents[cur][0];
|
||||
}
|
||||
|
||||
@@ -614,7 +618,7 @@ const noteTree = (function() {
|
||||
const newNode = {
|
||||
title: newNoteName,
|
||||
note_id: result.note_id,
|
||||
note_pid: parentNoteId,
|
||||
parent_note_id: parentNoteId,
|
||||
refKey: result.note_id,
|
||||
note_tree_id: result.note_tree_id,
|
||||
is_protected: isProtected,
|
||||
@@ -646,7 +650,7 @@ const noteTree = (function() {
|
||||
console.log("pressed O");
|
||||
|
||||
const node = getCurrentNode();
|
||||
const parentNoteId = node.data.note_pid;
|
||||
const parentNoteId = node.data.parent_note_id;
|
||||
const isProtected = treeUtils.getParentProtectedStatus(node);
|
||||
|
||||
createNote(node, parentNoteId, 'after', isProtected);
|
||||
|
||||
Reference in New Issue
Block a user