change in naming of SQL methods

added assert methods to note tree
This commit is contained in:
azivner
2017-12-23 11:02:38 -05:00
parent c07c18f08a
commit bd2a5f6d82
27 changed files with 139 additions and 85 deletions

View File

@@ -6,7 +6,7 @@ const notes = require('./notes');
const sync_table = require('./sync_table');
async function updateNote(entity, sourceId) {
const origNote = await sql.getSingleResult("SELECT * FROM notes WHERE note_id = ?", [entity.note_id]);
const origNote = await sql.getFirst("SELECT * FROM notes WHERE note_id = ?", [entity.note_id]);
if (!origNote || origNote.date_modified <= entity.date_modified) {
await sql.doInTransaction(async () => {
@@ -21,7 +21,7 @@ async function updateNote(entity, sourceId) {
}
async function updateNoteTree(entity, sourceId) {
const orig = await sql.getSingleResultOrNull("SELECT * FROM notes_tree WHERE note_tree_id = ?", [entity.note_tree_id]);
const orig = await sql.getFirstOrNull("SELECT * FROM notes_tree WHERE note_tree_id = ?", [entity.note_tree_id]);
await sql.doInTransaction(async () => {
if (orig === null || orig.date_modified < entity.date_modified) {
@@ -37,7 +37,7 @@ async function updateNoteTree(entity, sourceId) {
}
async function updateNoteHistory(entity, sourceId) {
const orig = await sql.getSingleResultOrNull("SELECT * FROM notes_history WHERE note_history_id = ?", [entity.note_history_id]);
const orig = await sql.getFirstOrNull("SELECT * FROM notes_history WHERE note_history_id = ?", [entity.note_history_id]);
await sql.doInTransaction(async () => {
if (orig === null || orig.date_modified_to < entity.date_modified_to) {
@@ -65,7 +65,7 @@ async function updateOptions(entity, sourceId) {
return;
}
const orig = await sql.getSingleResultOrNull("SELECT * FROM options WHERE opt_name = ?", [entity.opt_name]);
const orig = await sql.getFirstOrNull("SELECT * FROM options WHERE opt_name = ?", [entity.opt_name]);
await sql.doInTransaction(async () => {
if (orig === null || orig.date_modified < entity.date_modified) {
@@ -79,7 +79,7 @@ async function updateOptions(entity, sourceId) {
}
async function updateRecentNotes(entity, sourceId) {
const orig = await sql.getSingleResultOrNull("SELECT * FROM recent_notes WHERE note_tree_id = ?", [entity.note_tree_id]);
const orig = await sql.getFirstOrNull("SELECT * FROM recent_notes WHERE note_tree_id = ?", [entity.note_tree_id]);
if (orig === null || orig.date_accessed < entity.date_accessed) {
await sql.doInTransaction(async () => {