smaller refactorings

This commit is contained in:
azivner
2018-04-02 22:53:01 -04:00
parent a4e64350e9
commit 42dd8d4754
11 changed files with 32 additions and 69 deletions

View File

@@ -19,15 +19,13 @@ async function cloneNoteToParent(req) {
const maxNotePos = await sql.getValue('SELECT MAX(notePosition) FROM branches WHERE parentNoteId = ? AND isDeleted = 0', [parentNoteId]);
const newNotePos = maxNotePos === null ? 0 : maxNotePos + 1;
const branch = new Branch({
const branch = await new Branch({
noteId: noteId,
parentNoteId: parentNoteId,
prefix: prefix,
notePosition: newNotePos,
isExpanded: 0
});
await branch.save();
}).save();
await sql.execute("UPDATE branches SET isExpanded = 1 WHERE noteId = ?", [parentNoteId]);
@@ -53,14 +51,12 @@ async function cloneNoteAfter(req) {
await syncTable.addNoteReorderingSync(afterNote.parentNoteId);
const branch = new Branch({
const branch = await new Branch({
noteId: noteId,
parentNoteId: afterNote.parentNoteId,
notePosition: afterNote.notePosition + 1,
isExpanded: 0
});
await branch.save();
}).save();
return { success: true };
}

View File

@@ -24,14 +24,12 @@ async function addRecentNote(req) {
const branchId = req.params.branchId;
const notePath = req.params.notePath;
const recentNote = new RecentNote({
await new RecentNote({
branchId: branchId,
notePath: notePath,
dateAccessed: dateUtils.nowDate(),
isDeleted: 0
});
await recentNote.save();
}).save();
await optionService.setOption('startNotePath', notePath);

View File

@@ -20,8 +20,9 @@ async function login(req) {
return [401, "Incorrect username/password"];
}
const apiToken = new ApiToken({ token: utils.randomSecureToken() });
await apiToken.save();
const apiToken = await new ApiToken({
token: utils.randomSecureToken()
}).save();
return {
token: apiToken.token

View File

@@ -2,7 +2,6 @@
const sql = require('../../services/sql');
const optionService = require('../../services/options');
const config = require('../../services/config');
const protectedSessionService = require('../../services/protected_session');
async function getTree() {