mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 03:46:37 +01:00
bind global menu item "Open SQL console" to the logic to create such a note
This commit is contained in:
@@ -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
|
||||
};
|
||||
Reference in New Issue
Block a user