parent-child relationship is now stored in notes_parent table

This commit is contained in:
azivner
2017-11-18 18:57:50 -05:00
parent 9a819cafed
commit cc3c9d6428
5 changed files with 58 additions and 13 deletions

View File

@@ -19,7 +19,14 @@ router.get('/', auth.checkApiAuth, async (req, res, next) => {
+ "from notes_tree "
+ "join notes on notes.note_id = notes_tree.note_id "
+ "where notes.is_deleted = 0 and notes_tree.is_deleted = 0 "
+ "order by note_pid, note_pos");
+ "order by note_pos");
const notes_parent = await sql.getResults("" +
"select parent_id, child_id " +
"from notes_parent " +
"join notes_tree as child on child.note_tree_id = notes_parent.child_id " +
"left join notes_tree as parent on parent.note_tree_id = notes_parent.parent_id " +
"where child.is_deleted = 0 and (parent.is_deleted = 0 or notes_parent.parent_id = 'root')");
const dataKey = protected_session.getDataKey(req);
@@ -31,6 +38,7 @@ router.get('/', auth.checkApiAuth, async (req, res, next) => {
res.send({
notes: notes,
notes_parent: notes_parent,
start_note_tree_id: await options.getOption('start_note_tree_id'),
tree_load_time: utils.nowTimestamp()
});