mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 19:05:59 +01:00
created repository object to access entities
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
const sql = require('./sql');
|
||||
const utils = require('./utils');
|
||||
const sync_table = require('./sync_table');
|
||||
const protected_session = require('./protected_session');
|
||||
const Repository = require('./repository');
|
||||
|
||||
async function getNoteAttributeMap(noteId) {
|
||||
return await sql.getMap(`SELECT name, value FROM attributes WHERE noteId = ?`, [noteId]);
|
||||
@@ -15,21 +15,19 @@ async function getNoteIdWithAttribute(name, value) {
|
||||
}
|
||||
|
||||
async function getNotesWithAttribute(dataKey, name, value) {
|
||||
const repository = new Repository(dataKey);
|
||||
|
||||
let notes;
|
||||
|
||||
if (value !== undefined) {
|
||||
notes = await sql.getEntities(`SELECT notes.* FROM notes JOIN attributes USING(noteId)
|
||||
notes = await repository.getEntities(`SELECT notes.* FROM notes JOIN attributes USING(noteId)
|
||||
WHERE notes.isDeleted = 0 AND attributes.name = ? AND attributes.value = ?`, [name, value]);
|
||||
}
|
||||
else {
|
||||
notes = await sql.getEntities(`SELECT notes.* FROM notes JOIN attributes USING(noteId)
|
||||
notes = await repository.getEntities(`SELECT notes.* FROM notes JOIN attributes USING(noteId)
|
||||
WHERE notes.isDeleted = 0 AND attributes.name = ?`, [name]);
|
||||
}
|
||||
|
||||
for (const note of notes) {
|
||||
protected_session.decryptNote(dataKey, note);
|
||||
}
|
||||
|
||||
return notes;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user