mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 10:40:41 +01:00
renaming note_tree to branch
This commit is contained in:
@@ -24,7 +24,7 @@ router.post('/cleanup-soft-deleted-items', auth.checkApiAuth, wrap(async (req, r
|
||||
|
||||
await sql.execute(`DELETE FROM attributes WHERE noteId IN (${noteIdsSql})`);
|
||||
|
||||
await sql.execute("DELETE FROM note_tree WHERE isDeleted = 1");
|
||||
await sql.execute("DELETE FROM branches WHERE isDeleted = 1");
|
||||
|
||||
await sql.execute("DELETE FROM note_images WHERE isDeleted = 1");
|
||||
|
||||
@@ -35,9 +35,9 @@ router.post('/cleanup-soft-deleted-items', auth.checkApiAuth, wrap(async (req, r
|
||||
await sql.execute("DELETE FROM recent_notes");
|
||||
|
||||
await sync_table.cleanupSyncRowsForMissingEntities("notes", "noteId");
|
||||
await sync_table.cleanupSyncRowsForMissingEntities("note_tree", "noteTreeId");
|
||||
await sync_table.cleanupSyncRowsForMissingEntities("branches", "branchId");
|
||||
await sync_table.cleanupSyncRowsForMissingEntities("note_revisions", "noteRevisionId");
|
||||
await sync_table.cleanupSyncRowsForMissingEntities("recent_notes", "noteTreeId");
|
||||
await sync_table.cleanupSyncRowsForMissingEntities("recent_notes", "branchId");
|
||||
|
||||
log.info("Following notes has been completely cleaned from database: " + noteIdsSql);
|
||||
});
|
||||
|
||||
@@ -19,12 +19,12 @@ router.put('/:childNoteId/clone-to/:parentNoteId', auth.checkApiAuth, wrap(async
|
||||
return;
|
||||
}
|
||||
|
||||
const maxNotePos = await sql.getValue('SELECT MAX(notePosition) FROM note_tree WHERE parentNoteId = ? AND isDeleted = 0', [parentNoteId]);
|
||||
const maxNotePos = await sql.getValue('SELECT MAX(notePosition) FROM branches WHERE parentNoteId = ? AND isDeleted = 0', [parentNoteId]);
|
||||
const newNotePos = maxNotePos === null ? 0 : maxNotePos + 1;
|
||||
|
||||
await sql.doInTransaction(async () => {
|
||||
const noteTree = {
|
||||
noteTreeId: utils.newNoteTreeId(),
|
||||
const branch = {
|
||||
branchId: utils.newBranchId(),
|
||||
noteId: childNoteId,
|
||||
parentNoteId: parentNoteId,
|
||||
prefix: prefix,
|
||||
@@ -34,22 +34,22 @@ router.put('/:childNoteId/clone-to/:parentNoteId', auth.checkApiAuth, wrap(async
|
||||
isDeleted: 0
|
||||
};
|
||||
|
||||
await sql.replace("note_tree", noteTree);
|
||||
await sql.replace("branches", branch);
|
||||
|
||||
await sync_table.addNoteTreeSync(noteTree.noteTreeId, sourceId);
|
||||
await sync_table.addBranchSync(branch.branchId, sourceId);
|
||||
|
||||
await sql.execute("UPDATE note_tree SET isExpanded = 1 WHERE noteId = ?", [parentNoteId]);
|
||||
await sql.execute("UPDATE branches SET isExpanded = 1 WHERE noteId = ?", [parentNoteId]);
|
||||
});
|
||||
|
||||
res.send({ success: true });
|
||||
}));
|
||||
|
||||
router.put('/:noteId/clone-after/:afterNoteTreeId', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
router.put('/:noteId/clone-after/:afterBranchId', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const noteId = req.params.noteId;
|
||||
const afterNoteTreeId = req.params.afterNoteTreeId;
|
||||
const afterBranchId = req.params.afterBranchId;
|
||||
const sourceId = req.headers.source_id;
|
||||
|
||||
const afterNote = await tree.getNoteTree(afterNoteTreeId);
|
||||
const afterNote = await tree.getBranch(afterBranchId);
|
||||
|
||||
if (!await tree.validateParentChild(res, afterNote.parentNoteId, noteId)) {
|
||||
return;
|
||||
@@ -58,13 +58,13 @@ router.put('/:noteId/clone-after/:afterNoteTreeId', auth.checkApiAuth, wrap(asyn
|
||||
await sql.doInTransaction(async () => {
|
||||
// we don't change dateModified so other changes are prioritized in case of conflict
|
||||
// also we would have to sync all those modified note trees otherwise hash checks would fail
|
||||
await sql.execute("UPDATE note_tree SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition > ? AND isDeleted = 0",
|
||||
await sql.execute("UPDATE branches SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition > ? AND isDeleted = 0",
|
||||
[afterNote.parentNoteId, afterNote.notePosition]);
|
||||
|
||||
await sync_table.addNoteReorderingSync(afterNote.parentNoteId, sourceId);
|
||||
|
||||
const noteTree = {
|
||||
noteTreeId: utils.newNoteTreeId(),
|
||||
const branch = {
|
||||
branchId: utils.newBranchId(),
|
||||
noteId: noteId,
|
||||
parentNoteId: afterNote.parentNoteId,
|
||||
notePosition: afterNote.notePosition + 1,
|
||||
@@ -73,9 +73,9 @@ router.put('/:noteId/clone-after/:afterNoteTreeId', auth.checkApiAuth, wrap(asyn
|
||||
isDeleted: 0
|
||||
};
|
||||
|
||||
await sql.replace("note_tree", noteTree);
|
||||
await sql.replace("branches", branch);
|
||||
|
||||
await sync_table.addNoteTreeSync(noteTree.noteTreeId, sourceId);
|
||||
await sync_table.addBranchSync(branch.branchId, sourceId);
|
||||
});
|
||||
|
||||
res.send({ success: true });
|
||||
|
||||
@@ -14,11 +14,11 @@ router.get('/:noteId/', auth.checkApiAuthOrElectron, wrap(async (req, res, next)
|
||||
const noteId = req.params.noteId;
|
||||
const repo = new Repository(req);
|
||||
|
||||
const noteTreeId = await sql.getValue('SELECT noteTreeId FROM note_tree WHERE noteId = ?', [noteId]);
|
||||
const branchId = await sql.getValue('SELECT branchId FROM branches WHERE noteId = ?', [noteId]);
|
||||
|
||||
const pack = tar.pack();
|
||||
|
||||
const name = await exportNote(noteTreeId, '', pack, repo);
|
||||
const name = await exportNote(branchId, '', pack, repo);
|
||||
|
||||
pack.finalize();
|
||||
|
||||
@@ -28,9 +28,9 @@ router.get('/:noteId/', auth.checkApiAuthOrElectron, wrap(async (req, res, next)
|
||||
pack.pipe(res);
|
||||
}));
|
||||
|
||||
async function exportNote(noteTreeId, directory, pack, repo) {
|
||||
const noteTree = await sql.getRow("SELECT * FROM note_tree WHERE noteTreeId = ?", [noteTreeId]);
|
||||
const note = await repo.getEntity("SELECT notes.* FROM notes WHERE noteId = ?", [noteTree.noteId]);
|
||||
async function exportNote(branchId, directory, pack, repo) {
|
||||
const branch = await sql.getRow("SELECT * FROM branches WHERE branchId = ?", [branchId]);
|
||||
const note = await repo.getEntity("SELECT notes.* FROM notes WHERE noteId = ?", [branch.noteId]);
|
||||
|
||||
if (note.isProtected) {
|
||||
return;
|
||||
@@ -51,11 +51,11 @@ async function exportNote(noteTreeId, directory, pack, repo) {
|
||||
|
||||
pack.entry({ name: childFileName + ".dat", size: content.length }, content);
|
||||
|
||||
const children = await sql.getRows("SELECT * FROM note_tree WHERE parentNoteId = ? AND isDeleted = 0", [note.noteId]);
|
||||
const children = await sql.getRows("SELECT * FROM branches WHERE parentNoteId = ? AND isDeleted = 0", [note.noteId]);
|
||||
|
||||
if (children.length > 0) {
|
||||
for (const child of children) {
|
||||
await exportNote(child.noteTreeId, childFileName + "/", pack, repo);
|
||||
await exportNote(child.branchId, childFileName + "/", pack, repo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,11 +48,11 @@ router.post('/:parentNoteId/children', auth.checkApiAuth, wrap(async (req, res,
|
||||
const newNote = req.body;
|
||||
|
||||
await sql.doInTransaction(async () => {
|
||||
const { noteId, noteTreeId, note } = await notes.createNewNote(parentNoteId, newNote, req, sourceId);
|
||||
const { noteId, branchId, note } = await notes.createNewNote(parentNoteId, newNote, req, sourceId);
|
||||
|
||||
res.send({
|
||||
'noteId': noteId,
|
||||
'noteTreeId': noteTreeId,
|
||||
'branchId': branchId,
|
||||
'note': note
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,20 +13,20 @@ router.get('', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
res.send(await getRecentNotes());
|
||||
}));
|
||||
|
||||
router.put('/:noteTreeId/:notePath', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const noteTreeId = req.params.noteTreeId;
|
||||
router.put('/:branchId/:notePath', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const branchId = req.params.branchId;
|
||||
const notePath = req.params.notePath;
|
||||
const sourceId = req.headers.source_id;
|
||||
|
||||
await sql.doInTransaction(async () => {
|
||||
await sql.replace('recent_notes', {
|
||||
noteTreeId: noteTreeId,
|
||||
branchId: branchId,
|
||||
notePath: notePath,
|
||||
dateAccessed: utils.nowDate(),
|
||||
isDeleted: 0
|
||||
});
|
||||
|
||||
await sync_table.addRecentNoteSync(noteTreeId, sourceId);
|
||||
await sync_table.addRecentNoteSync(branchId, sourceId);
|
||||
|
||||
await options.setOption('start_note_path', notePath, sourceId);
|
||||
});
|
||||
@@ -40,10 +40,10 @@ async function getRecentNotes() {
|
||||
recent_notes.*
|
||||
FROM
|
||||
recent_notes
|
||||
JOIN note_tree USING(noteTreeId)
|
||||
JOIN branches USING(branchId)
|
||||
WHERE
|
||||
recent_notes.isDeleted = 0
|
||||
AND note_tree.isDeleted = 0
|
||||
AND branches.isDeleted = 0
|
||||
ORDER BY
|
||||
dateAccessed DESC
|
||||
LIMIT 200`);
|
||||
|
||||
@@ -53,9 +53,9 @@ router.post('/force-note-sync/:noteId', auth.checkApiAuth, wrap(async (req, res,
|
||||
await sql.doInTransaction(async () => {
|
||||
await sync_table.addNoteSync(noteId);
|
||||
|
||||
for (const noteTreeId of await sql.getColumn("SELECT noteTreeId FROM note_tree WHERE isDeleted = 0 AND noteId = ?", [noteId])) {
|
||||
await sync_table.addNoteTreeSync(noteTreeId);
|
||||
await sync_table.addRecentNoteSync(noteTreeId);
|
||||
for (const branchId of await sql.getColumn("SELECT branchId FROM branches WHERE isDeleted = 0 AND noteId = ?", [noteId])) {
|
||||
await sync_table.addBranchSync(branchId);
|
||||
await sync_table.addRecentNoteSync(branchId);
|
||||
}
|
||||
|
||||
for (const noteRevisionId of await sql.getColumn("SELECT noteRevisionId FROM note_revisions WHERE noteId = ?", [noteId])) {
|
||||
@@ -88,10 +88,10 @@ router.get('/notes/:noteId', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
});
|
||||
}));
|
||||
|
||||
router.get('/note_tree/:noteTreeId', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const noteTreeId = req.params.noteTreeId;
|
||||
router.get('/branches/:branchId', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const branchId = req.params.branchId;
|
||||
|
||||
res.send(await sql.getRow("SELECT * FROM note_tree WHERE noteTreeId = ?", [noteTreeId]));
|
||||
res.send(await sql.getRow("SELECT * FROM branches WHERE branchId = ?", [branchId]));
|
||||
}));
|
||||
|
||||
router.get('/note_revisions/:noteRevisionId', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
@@ -117,14 +117,14 @@ router.get('/note_reordering/:parentNoteId', auth.checkApiAuth, wrap(async (req,
|
||||
|
||||
res.send({
|
||||
parentNoteId: parentNoteId,
|
||||
ordering: await sql.getMap("SELECT noteTreeId, notePosition FROM note_tree WHERE parentNoteId = ? AND isDeleted = 0", [parentNoteId])
|
||||
ordering: await sql.getMap("SELECT branchId, notePosition FROM branches WHERE parentNoteId = ? AND isDeleted = 0", [parentNoteId])
|
||||
});
|
||||
}));
|
||||
|
||||
router.get('/recent_notes/:noteTreeId', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const noteTreeId = req.params.noteTreeId;
|
||||
router.get('/recent_notes/:branchId', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const branchId = req.params.branchId;
|
||||
|
||||
res.send(await sql.getRow("SELECT * FROM recent_notes WHERE noteTreeId = ?", [noteTreeId]));
|
||||
res.send(await sql.getRow("SELECT * FROM recent_notes WHERE branchId = ?", [branchId]));
|
||||
}));
|
||||
|
||||
router.get('/images/:imageId', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
@@ -162,8 +162,8 @@ router.put('/notes', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
res.send({});
|
||||
}));
|
||||
|
||||
router.put('/note_tree', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
await syncUpdate.updateNoteTree(req.body.entity, req.body.sourceId);
|
||||
router.put('/branches', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
await syncUpdate.updateBranch(req.body.entity, req.body.sourceId);
|
||||
|
||||
res.send({});
|
||||
}));
|
||||
|
||||
@@ -12,16 +12,16 @@ const sync_table = require('../../services/sync_table');
|
||||
const wrap = require('express-promise-wrap').wrap;
|
||||
|
||||
router.get('/', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const noteTree = await sql.getRows(`
|
||||
const branches = await sql.getRows(`
|
||||
SELECT
|
||||
noteTreeId,
|
||||
branchId,
|
||||
noteId,
|
||||
parentNoteId,
|
||||
notePosition,
|
||||
prefix,
|
||||
isExpanded
|
||||
FROM
|
||||
note_tree
|
||||
branches
|
||||
WHERE
|
||||
isDeleted = 0
|
||||
ORDER BY
|
||||
@@ -60,21 +60,21 @@ router.get('/', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
|
||||
res.send({
|
||||
instanceName: config.General ? config.General.instanceName : null,
|
||||
noteTree: noteTree,
|
||||
branches: branches,
|
||||
notes: notes,
|
||||
start_note_path: await options.getOption('start_note_path')
|
||||
});
|
||||
}));
|
||||
|
||||
router.put('/:noteTreeId/set-prefix', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const noteTreeId = req.params.noteTreeId;
|
||||
router.put('/:branchId/set-prefix', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const branchId = req.params.branchId;
|
||||
const sourceId = req.headers.source_id;
|
||||
const prefix = utils.isEmptyOrWhitespace(req.body.prefix) ? null : req.body.prefix;
|
||||
|
||||
await sql.doInTransaction(async () => {
|
||||
await sql.execute("UPDATE note_tree SET prefix = ?, dateModified = ? WHERE noteTreeId = ?", [prefix, utils.nowDate(), noteTreeId]);
|
||||
await sql.execute("UPDATE branches SET prefix = ?, dateModified = ? WHERE branchId = ?", [prefix, utils.nowDate(), branchId]);
|
||||
|
||||
await sync_table.addNoteTreeSync(noteTreeId, sourceId);
|
||||
await sync_table.addBranchSync(branchId, sourceId);
|
||||
});
|
||||
|
||||
res.send({});
|
||||
|
||||
@@ -15,96 +15,96 @@ const wrap = require('express-promise-wrap').wrap;
|
||||
* for not deleted note trees. There may be multiple deleted note-parent note relationships.
|
||||
*/
|
||||
|
||||
router.put('/:noteTreeId/move-to/:parentNoteId', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const noteTreeId = req.params.noteTreeId;
|
||||
router.put('/:branchId/move-to/:parentNoteId', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const branchId = req.params.branchId;
|
||||
const parentNoteId = req.params.parentNoteId;
|
||||
const sourceId = req.headers.source_id;
|
||||
|
||||
const noteToMove = await tree.getNoteTree(noteTreeId);
|
||||
const noteToMove = await tree.getBranch(branchId);
|
||||
|
||||
if (!await tree.validateParentChild(res, parentNoteId, noteToMove.noteId, noteTreeId)) {
|
||||
if (!await tree.validateParentChild(res, parentNoteId, noteToMove.noteId, branchId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const maxNotePos = await sql.getValue('SELECT MAX(notePosition) FROM note_tree WHERE parentNoteId = ? AND isDeleted = 0', [parentNoteId]);
|
||||
const maxNotePos = await sql.getValue('SELECT MAX(notePosition) FROM branches WHERE parentNoteId = ? AND isDeleted = 0', [parentNoteId]);
|
||||
const newNotePos = maxNotePos === null ? 0 : maxNotePos + 1;
|
||||
|
||||
const now = utils.nowDate();
|
||||
|
||||
await sql.doInTransaction(async () => {
|
||||
await sql.execute("UPDATE note_tree SET parentNoteId = ?, notePosition = ?, dateModified = ? WHERE noteTreeId = ?",
|
||||
[parentNoteId, newNotePos, now, noteTreeId]);
|
||||
await sql.execute("UPDATE branches SET parentNoteId = ?, notePosition = ?, dateModified = ? WHERE branchId = ?",
|
||||
[parentNoteId, newNotePos, now, branchId]);
|
||||
|
||||
await sync_table.addNoteTreeSync(noteTreeId, sourceId);
|
||||
await sync_table.addBranchSync(branchId, sourceId);
|
||||
});
|
||||
|
||||
res.send({ success: true });
|
||||
}));
|
||||
|
||||
router.put('/:noteTreeId/move-before/:beforeNoteTreeId', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const noteTreeId = req.params.noteTreeId;
|
||||
const beforeNoteTreeId = req.params.beforeNoteTreeId;
|
||||
router.put('/:branchId/move-before/:beforeBranchId', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const branchId = req.params.branchId;
|
||||
const beforeBranchId = req.params.beforeBranchId;
|
||||
const sourceId = req.headers.source_id;
|
||||
|
||||
const noteToMove = await tree.getNoteTree(noteTreeId);
|
||||
const beforeNote = await tree.getNoteTree(beforeNoteTreeId);
|
||||
const noteToMove = await tree.getBranch(branchId);
|
||||
const beforeNote = await tree.getBranch(beforeBranchId);
|
||||
|
||||
if (!await tree.validateParentChild(res, beforeNote.parentNoteId, noteToMove.noteId, noteTreeId)) {
|
||||
if (!await tree.validateParentChild(res, beforeNote.parentNoteId, noteToMove.noteId, branchId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
await sql.doInTransaction(async () => {
|
||||
// we don't change dateModified so other changes are prioritized in case of conflict
|
||||
// also we would have to sync all those modified note trees otherwise hash checks would fail
|
||||
await sql.execute("UPDATE note_tree SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition >= ? AND isDeleted = 0",
|
||||
await sql.execute("UPDATE branches SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition >= ? AND isDeleted = 0",
|
||||
[beforeNote.parentNoteId, beforeNote.notePosition]);
|
||||
|
||||
await sync_table.addNoteReorderingSync(beforeNote.parentNoteId, sourceId);
|
||||
|
||||
await sql.execute("UPDATE note_tree SET parentNoteId = ?, notePosition = ?, dateModified = ? WHERE noteTreeId = ?",
|
||||
[beforeNote.parentNoteId, beforeNote.notePosition, utils.nowDate(), noteTreeId]);
|
||||
await sql.execute("UPDATE branches SET parentNoteId = ?, notePosition = ?, dateModified = ? WHERE branchId = ?",
|
||||
[beforeNote.parentNoteId, beforeNote.notePosition, utils.nowDate(), branchId]);
|
||||
|
||||
await sync_table.addNoteTreeSync(noteTreeId, sourceId);
|
||||
await sync_table.addBranchSync(branchId, sourceId);
|
||||
});
|
||||
|
||||
res.send({ success: true });
|
||||
}));
|
||||
|
||||
router.put('/:noteTreeId/move-after/:afterNoteTreeId', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const noteTreeId = req.params.noteTreeId;
|
||||
const afterNoteTreeId = req.params.afterNoteTreeId;
|
||||
router.put('/:branchId/move-after/:afterBranchId', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const branchId = req.params.branchId;
|
||||
const afterBranchId = req.params.afterBranchId;
|
||||
const sourceId = req.headers.source_id;
|
||||
|
||||
const noteToMove = await tree.getNoteTree(noteTreeId);
|
||||
const afterNote = await tree.getNoteTree(afterNoteTreeId);
|
||||
const noteToMove = await tree.getBranch(branchId);
|
||||
const afterNote = await tree.getBranch(afterBranchId);
|
||||
|
||||
if (!await tree.validateParentChild(res, afterNote.parentNoteId, noteToMove.noteId, noteTreeId)) {
|
||||
if (!await tree.validateParentChild(res, afterNote.parentNoteId, noteToMove.noteId, branchId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
await sql.doInTransaction(async () => {
|
||||
// we don't change dateModified so other changes are prioritized in case of conflict
|
||||
// also we would have to sync all those modified note trees otherwise hash checks would fail
|
||||
await sql.execute("UPDATE note_tree SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition > ? AND isDeleted = 0",
|
||||
await sql.execute("UPDATE branches SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition > ? AND isDeleted = 0",
|
||||
[afterNote.parentNoteId, afterNote.notePosition]);
|
||||
|
||||
await sync_table.addNoteReorderingSync(afterNote.parentNoteId, sourceId);
|
||||
|
||||
await sql.execute("UPDATE note_tree SET parentNoteId = ?, notePosition = ?, dateModified = ? WHERE noteTreeId = ?",
|
||||
[afterNote.parentNoteId, afterNote.notePosition + 1, utils.nowDate(), noteTreeId]);
|
||||
await sql.execute("UPDATE branches SET parentNoteId = ?, notePosition = ?, dateModified = ? WHERE branchId = ?",
|
||||
[afterNote.parentNoteId, afterNote.notePosition + 1, utils.nowDate(), branchId]);
|
||||
|
||||
await sync_table.addNoteTreeSync(noteTreeId, sourceId);
|
||||
await sync_table.addBranchSync(branchId, sourceId);
|
||||
});
|
||||
|
||||
res.send({ success: true });
|
||||
}));
|
||||
|
||||
router.put('/:noteTreeId/expanded/:expanded', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const noteTreeId = req.params.noteTreeId;
|
||||
router.put('/:branchId/expanded/:expanded', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const branchId = req.params.branchId;
|
||||
const expanded = req.params.expanded;
|
||||
|
||||
await sql.doInTransaction(async () => {
|
||||
await sql.execute("UPDATE note_tree SET isExpanded = ? WHERE noteTreeId = ?", [expanded, noteTreeId]);
|
||||
await sql.execute("UPDATE branches SET isExpanded = ? WHERE branchId = ?", [expanded, branchId]);
|
||||
|
||||
// we don't sync expanded attribute
|
||||
});
|
||||
@@ -112,9 +112,9 @@ router.put('/:noteTreeId/expanded/:expanded', auth.checkApiAuth, wrap(async (req
|
||||
res.send({});
|
||||
}));
|
||||
|
||||
router.delete('/:noteTreeId', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
router.delete('/:branchId', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
await sql.doInTransaction(async () => {
|
||||
await notes.deleteNote(req.params.noteTreeId, req.headers.source_id);
|
||||
await notes.deleteNote(req.params.branchId, req.headers.source_id);
|
||||
});
|
||||
|
||||
res.send({});
|
||||
|
||||
Reference in New Issue
Block a user