consistent checking of is_deleted, some small refactorings

This commit is contained in:
azivner
2018-01-03 22:13:02 -05:00
parent 353a9b24c1
commit 07c33979c3
7 changed files with 32 additions and 22 deletions

View File

@@ -12,14 +12,20 @@ const notes = require('../../services/notes');
const sync_table = require('../../services/sync_table');
router.get('/', auth.checkApiAuth, async (req, res, next) => {
const notes = await sql.getAll("SELECT "
+ "notes_tree.*, "
+ "notes.note_title, "
+ "notes.is_protected "
+ "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_position");
const notes = await sql.getAll(`
SELECT
notes_tree.*,
notes.note_title,
notes.is_protected
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_position`);
const dataKey = protected_session.getDataKey(req);