mirror of
https://github.com/zadam/trilium.git
synced 2025-11-04 20:36:13 +01:00
converted all timestamps to string representation
This commit is contained in:
@@ -67,6 +67,8 @@ async function importNotes(dir, parentNoteId) {
|
||||
const noteId = utils.newNoteId();
|
||||
const noteTreeId = utils.newNoteHistoryId();
|
||||
|
||||
const now = utils.nowDate();
|
||||
|
||||
await sql.insert('notes_tree', {
|
||||
note_tree_id: noteTreeId,
|
||||
note_id: noteId,
|
||||
@@ -74,7 +76,7 @@ async function importNotes(dir, parentNoteId) {
|
||||
note_pos: notePos,
|
||||
is_expanded: 0,
|
||||
is_deleted: 0,
|
||||
date_modified: utils.nowTimestamp()
|
||||
date_modified: now
|
||||
});
|
||||
|
||||
await sync_table.addNoteTreeSync(noteTreeId);
|
||||
@@ -85,8 +87,8 @@ async function importNotes(dir, parentNoteId) {
|
||||
note_text: noteText,
|
||||
is_deleted: 0,
|
||||
is_protected: 0,
|
||||
date_created: utils.nowTimestamp(),
|
||||
date_modified: utils.nowTimestamp()
|
||||
date_created: now,
|
||||
date_modified: now
|
||||
});
|
||||
|
||||
await sync_table.addNoteSync(noteId);
|
||||
|
||||
@@ -4,7 +4,6 @@ const express = require('express');
|
||||
const router = express.Router();
|
||||
const options = require('../../services/options');
|
||||
const utils = require('../../services/utils');
|
||||
const migration = require('../../services/migration');
|
||||
const source_id = require('../../services/source_id');
|
||||
const auth = require('../../services/auth');
|
||||
const password_encryption = require('../../services/password_encryption');
|
||||
|
||||
@@ -30,8 +30,7 @@ router.get('/:noteId', auth.checkApiAuth, async (req, res, next) => {
|
||||
}
|
||||
|
||||
res.send({
|
||||
detail: detail,
|
||||
loadTime: utils.nowTimestamp()
|
||||
detail: detail
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ router.put('/:noteTreeId/move-to/:parentNoteId', auth.checkApiAuth, async (req,
|
||||
const maxNotePos = await sql.getSingleValue('SELECT MAX(note_pos) FROM notes_tree WHERE note_pid = ? AND is_deleted = 0', [parentNoteId]);
|
||||
const newNotePos = maxNotePos === null ? 0 : maxNotePos + 1;
|
||||
|
||||
const now = utils.nowTimestamp();
|
||||
const now = utils.nowDate();
|
||||
|
||||
await sql.doInTransaction(async () => {
|
||||
await sql.execute("UPDATE notes_tree SET note_pid = ?, note_pos = ?, date_modified = ? WHERE note_tree_id = ?",
|
||||
@@ -40,7 +40,7 @@ router.put('/:noteTreeId/move-before/:beforeNoteTreeId', async (req, res, next)
|
||||
|
||||
await sync_table.addNoteReorderingSync(beforeNote.note_pid);
|
||||
|
||||
const now = utils.nowTimestamp();
|
||||
const now = utils.nowDate();
|
||||
|
||||
await sql.execute("UPDATE notes_tree SET note_pid = ?, note_pos = ?, date_modified = ? WHERE note_tree_id = ?",
|
||||
[beforeNote.note_pid, beforeNote.note_pos, now, noteTreeId]);
|
||||
@@ -70,7 +70,7 @@ router.put('/:noteTreeId/move-after/:afterNoteTreeId', async (req, res, next) =>
|
||||
await sync_table.addNoteReorderingSync(afterNote.note_pid);
|
||||
|
||||
await sql.execute("UPDATE notes_tree SET note_pid = ?, note_pos = ?, date_modified = ? WHERE note_tree_id = ?",
|
||||
[afterNote.note_pid, afterNote.note_pos + 1, utils.nowTimestamp(), noteTreeId]);
|
||||
[afterNote.note_pid, afterNote.note_pos + 1, utils.nowDate(), noteTreeId]);
|
||||
|
||||
await sync_table.addNoteTreeSync(noteTreeId);
|
||||
});
|
||||
@@ -107,13 +107,13 @@ router.put('/:childNoteId/clone-to/:parentNoteId', auth.checkApiAuth, async (req
|
||||
|
||||
await sql.doInTransaction(async () => {
|
||||
const noteTree = {
|
||||
'note_tree_id': utils.newNoteTreeId(),
|
||||
'note_id': childNoteId,
|
||||
'note_pid': parentNoteId,
|
||||
'note_pos': newNotePos,
|
||||
'is_expanded': 0,
|
||||
'date_modified': utils.nowTimestamp(),
|
||||
'is_deleted': 0
|
||||
note_tree_id: utils.newNoteTreeId(),
|
||||
note_id: childNoteId,
|
||||
note_pid: parentNoteId,
|
||||
note_pos: newNotePos,
|
||||
is_expanded: 0,
|
||||
date_modified: utils.nowDate(),
|
||||
is_deleted: 0
|
||||
};
|
||||
|
||||
await sql.replace("notes_tree", noteTree);
|
||||
@@ -160,13 +160,13 @@ router.put('/:noteId/clone-after/:afterNoteTreeId', async (req, res, next) => {
|
||||
await sync_table.addNoteReorderingSync(afterNote.note_pid);
|
||||
|
||||
const noteTree = {
|
||||
'note_tree_id': utils.newNoteTreeId(),
|
||||
'note_id': noteId,
|
||||
'note_pid': afterNote.note_pid,
|
||||
'note_pos': afterNote.note_pos + 1,
|
||||
'is_expanded': 0,
|
||||
'date_modified': utils.nowTimestamp(),
|
||||
'is_deleted': 0
|
||||
note_tree_id: utils.newNoteTreeId(),
|
||||
note_id: noteId,
|
||||
note_pid: afterNote.note_pid,
|
||||
note_pos: afterNote.note_pos + 1,
|
||||
is_expanded: 0,
|
||||
date_modified: utils.nowDate(),
|
||||
is_deleted: 0
|
||||
};
|
||||
|
||||
await sql.replace("notes_tree", noteTree);
|
||||
|
||||
@@ -20,7 +20,7 @@ router.put('/:noteTreeId/:notePath', auth.checkApiAuth, async (req, res, next) =
|
||||
await sql.replace('recent_notes', {
|
||||
note_tree_id: noteTreeId,
|
||||
note_path: notePath,
|
||||
date_accessed: utils.nowTimestamp(),
|
||||
date_accessed: utils.nowDate(),
|
||||
is_deleted: 0
|
||||
});
|
||||
|
||||
@@ -39,7 +39,7 @@ async function getRecentNotes() {
|
||||
}
|
||||
|
||||
async function deleteOld() {
|
||||
const cutoffDateAccessed = utils.nowTimestamp() - 24 * 60 * 60;
|
||||
const cutoffDateAccessed = utils.dateStr(new Date(Date.now() - 24 * 60 * 60 * 1000));
|
||||
|
||||
await sql.doInTransaction(async () => {
|
||||
await sql.execute("DELETE FROM recent_notes WHERE date_accessed < ?", [cutoffDateAccessed]);
|
||||
|
||||
@@ -52,7 +52,7 @@ router.put('/:noteTreeId/set-prefix', auth.checkApiAuth, async (req, res, next)
|
||||
const prefix = utils.isEmptyOrWhitespace(req.body.prefix) ? null : req.body.prefix;
|
||||
|
||||
await sql.doInTransaction(async () => {
|
||||
await sql.execute("UPDATE notes_tree SET prefix = ?, date_modified = ? WHERE note_tree_id = ?", [prefix, utils.nowTimestamp(), noteTreeId]);
|
||||
await sql.execute("UPDATE notes_tree SET prefix = ?, date_modified = ? WHERE note_tree_id = ?", [prefix, utils.nowDate(), noteTreeId]);
|
||||
|
||||
await sync_table.addNoteTreeSync(noteTreeId);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user