mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 19:36:12 +01:00
renaming of sql methods to fit getRows/getEntities model
This commit is contained in:
@@ -28,7 +28,7 @@ async function validateParentChild(res, parentNoteId, childNoteId, noteTreeId =
|
||||
}
|
||||
|
||||
async function getExistingNoteTree(parentNoteId, childNoteId) {
|
||||
return await sql.getFirst('SELECT * FROM note_tree WHERE noteId = ? AND parentNoteId = ? AND isDeleted = 0', [childNoteId, parentNoteId]);
|
||||
return await sql.getRow('SELECT * FROM note_tree WHERE noteId = ? AND parentNoteId = ? AND isDeleted = 0', [childNoteId, parentNoteId]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +51,7 @@ async function checkTreeCycle(parentNoteId, childNoteId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const parentNoteIds = await sql.getFirstColumn("SELECT DISTINCT parentNoteId FROM note_tree WHERE noteId = ? AND isDeleted = 0", [parentNoteId]);
|
||||
const parentNoteIds = await sql.getColumn("SELECT DISTINCT parentNoteId FROM note_tree WHERE noteId = ? AND isDeleted = 0", [parentNoteId]);
|
||||
|
||||
for (const pid of parentNoteIds) {
|
||||
if (!await checkTreeCycleInner(pid)) {
|
||||
@@ -66,13 +66,13 @@ async function checkTreeCycle(parentNoteId, childNoteId) {
|
||||
}
|
||||
|
||||
async function getNoteTree(noteTreeId) {
|
||||
return sql.getFirst("SELECT * FROM note_tree WHERE noteTreeId = ?", [noteTreeId]);
|
||||
return sql.getRow("SELECT * FROM note_tree WHERE noteTreeId = ?", [noteTreeId]);
|
||||
}
|
||||
|
||||
async function loadSubTreeNoteIds(parentNoteId, subTreeNoteIds) {
|
||||
subTreeNoteIds.push(parentNoteId);
|
||||
|
||||
const children = await sql.getFirstColumn("SELECT noteId FROM note_tree WHERE parentNoteId = ? AND isDeleted = 0", [parentNoteId]);
|
||||
const children = await sql.getColumn("SELECT noteId FROM note_tree WHERE parentNoteId = ? AND isDeleted = 0", [parentNoteId]);
|
||||
|
||||
for (const childNoteId of children) {
|
||||
await loadSubTreeNoteIds(childNoteId, subTreeNoteIds);
|
||||
@@ -81,7 +81,7 @@ async function loadSubTreeNoteIds(parentNoteId, subTreeNoteIds) {
|
||||
|
||||
async function sortNotesAlphabetically(parentNoteId, req, sourceId) {
|
||||
await sql.doInTransaction(async () => {
|
||||
const notes = await sql.getAll(`SELECT noteTreeId, noteId, title, isProtected
|
||||
const notes = await sql.getRows(`SELECT noteTreeId, noteId, title, isProtected
|
||||
FROM notes JOIN note_tree USING(noteId)
|
||||
WHERE note_tree.isDeleted = 0 AND parentNoteId = ?`, [parentNoteId]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user