bind global menu item "Open SQL console" to the logic to create such a note

This commit is contained in:
zadam
2020-05-08 23:39:46 +02:00
parent c3438e0f3f
commit d20415c979
9 changed files with 67 additions and 24 deletions

View File

@@ -2,6 +2,8 @@
const dateNoteService = require('../../services/date_notes');
const sql = require('../../services/sql');
const dateUtils = require('../../services/date_utils');
const noteService = require('../../services/notes');
async function getDateNote(req) {
return await dateNoteService.getDateNote(req.params.date);
@@ -31,9 +33,28 @@ async function getDateNotesForMonth(req) {
AND attr.value LIKE '${month}%'`);
}
async function createSqlConsole() {
const today = dateUtils.localNowDate();
const todayNote = await dateNoteService.getDateNote(today);
const {note} = await noteService.createNewNote({
parentNoteId: todayNote.noteId,
title: 'SQL Console',
content: "SELECT title, isDeleted, isProtected FROM notes WHERE noteId = ''\n\n\n\n",
type: 'code',
mime: 'text/x-sqlite;schema=trilium'
});
await note.setLabel("sqlConsole", today);
return note;
}
module.exports = {
getDateNote,
getMonthNote,
getYearNote,
getDateNotesForMonth
getDateNotesForMonth,
createSqlConsole
};