mirror of
https://github.com/zadam/trilium.git
synced 2025-11-18 03:00:41 +01:00
#125, implementation of inheritable relations
This commit is contained in:
@@ -36,9 +36,23 @@ async function createRelation(sourceNoteId, name, targetNoteId) {
|
||||
}).save();
|
||||
}
|
||||
|
||||
async function getEffectiveRelations(noteId) {
|
||||
return await repository.getEntities(`
|
||||
WITH RECURSIVE tree(noteId) AS (
|
||||
SELECT ?
|
||||
UNION
|
||||
SELECT branches.parentNoteId FROM branches
|
||||
JOIN tree ON branches.noteId = tree.noteId
|
||||
JOIN notes ON notes.noteId = branches.parentNoteId
|
||||
WHERE notes.isDeleted = 0 AND branches.isDeleted = 0
|
||||
)
|
||||
SELECT relations.* FROM relations JOIN tree ON relations.sourceNoteId = tree.noteId WHERE relations.isDeleted = 0 AND relations.name IN ('runOnNoteView')`, [noteId]);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
BUILTIN_RELATIONS,
|
||||
getNotesWithRelation,
|
||||
getNoteWithRelation,
|
||||
createRelation,
|
||||
BUILTIN_RELATIONS
|
||||
getEffectiveRelations
|
||||
};
|
||||
@@ -139,8 +139,14 @@ function sanitizeVariableName(str) {
|
||||
return str.replace(/[^a-z0-9_]/gim, "");
|
||||
}
|
||||
|
||||
async function getScriptBundleForNoteId(noteId) {
|
||||
const note = await repository.getNote(noteId);
|
||||
return await getScriptBundle(note);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
executeNote,
|
||||
executeScript,
|
||||
getScriptBundle
|
||||
getScriptBundle,
|
||||
getScriptBundleForNoteId
|
||||
};
|
||||
Reference in New Issue
Block a user