mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
simplification of script bundles on backend
This commit is contained in:
parent
3d8905207e
commit
f7f0560a9f
@ -53,14 +53,21 @@ async function getRelationBundles(req) {
|
|||||||
const bundles = [];
|
const bundles = [];
|
||||||
|
|
||||||
for (const noteId of uniqueNoteIds) {
|
for (const noteId of uniqueNoteIds) {
|
||||||
bundles.push(await scriptService.getScriptBundleForNoteId(noteId));
|
const note = await repository.getNote(noteId);
|
||||||
|
const bundle = await scriptService.getScriptBundle(note);
|
||||||
|
|
||||||
|
if (bundle) {
|
||||||
|
bundles.push(bundle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return bundles;
|
return bundles;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getBundle(req) {
|
async function getBundle(req) {
|
||||||
return await scriptService.getScriptBundleForNoteId(req.params.noteId);
|
const note = await repository.getNote(req.params.noteId);
|
||||||
|
|
||||||
|
return await scriptService.getScriptBundle(note);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -47,11 +47,6 @@ async function getBranch(branchId) {
|
|||||||
return await getEntity("SELECT * FROM branches WHERE branchId = ?", [branchId]);
|
return await getEntity("SELECT * FROM branches WHERE branchId = ?", [branchId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {Image|null} */
|
|
||||||
async function getImage(imageId) {
|
|
||||||
return await getEntity("SELECT * FROM images WHERE imageId = ?", [imageId]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @returns {Attribute|null} */
|
/** @returns {Attribute|null} */
|
||||||
async function getAttribute(attributeId) {
|
async function getAttribute(attributeId) {
|
||||||
return await getEntity("SELECT * FROM attributes WHERE attributeId = ?", [attributeId]);
|
return await getEntity("SELECT * FROM attributes WHERE attributeId = ?", [attributeId]);
|
||||||
|
@ -153,14 +153,8 @@ function sanitizeVariableName(str) {
|
|||||||
return str.replace(/[^a-z0-9_]/gim, "");
|
return str.replace(/[^a-z0-9_]/gim, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getScriptBundleForNoteId(noteId) {
|
|
||||||
const note = await repository.getNote(noteId);
|
|
||||||
return await getScriptBundle(note);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
executeNote,
|
executeNote,
|
||||||
executeScript,
|
executeScript,
|
||||||
getScriptBundle,
|
getScriptBundle
|
||||||
getScriptBundleForNoteId
|
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user