mirror of
https://github.com/zadam/trilium.git
synced 2025-11-12 00:05:50 +01:00
WIP blobs
This commit is contained in:
@@ -12,7 +12,7 @@ const CREDENTIALS = 'shareCredentials';
|
||||
const isCredentials = attr => attr.type === 'label' && attr.name === CREDENTIALS;
|
||||
|
||||
class SNote extends AbstractShacaEntity {
|
||||
constructor([noteId, title, type, mime, utcDateModified, isProtected]) {
|
||||
constructor([noteId, title, type, mime, blobId, utcDateModified, isProtected]) {
|
||||
super();
|
||||
|
||||
/** @param {string} */
|
||||
@@ -24,6 +24,8 @@ class SNote extends AbstractShacaEntity {
|
||||
/** @param {string} */
|
||||
this.mime = mime;
|
||||
/** @param {string} */
|
||||
this.blobId = blobId;
|
||||
/** @param {string} */
|
||||
this.utcDateModified = utcDateModified; // used for caching of images
|
||||
/** @param {boolean} */
|
||||
this.isProtected = isProtected;
|
||||
@@ -92,14 +94,14 @@ class SNote extends AbstractShacaEntity {
|
||||
}
|
||||
|
||||
getContent(silentNotFoundError = false) {
|
||||
const row = sql.getRow(`SELECT content FROM note_contents WHERE noteId = ?`, [this.noteId]);
|
||||
const row = sql.getRow(`SELECT content FROM blobs WHERE blobId = ?`, [this.blobId]);
|
||||
|
||||
if (!row) {
|
||||
if (silentNotFoundError) {
|
||||
return undefined;
|
||||
}
|
||||
else {
|
||||
throw new Error(`Cannot find note content for noteId=${this.noteId}`);
|
||||
throw new Error(`Cannot find note content for noteId '${this.noteId}', blobId '${this.blobId}'`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ function load() {
|
||||
const noteIdStr = noteIds.map(noteId => `'${noteId}'`).join(",");
|
||||
|
||||
const rawNoteRows = sql.getRawRows(`
|
||||
SELECT noteId, title, type, mime, utcDateModified, isProtected
|
||||
SELECT noteId, title, type, mime, blobId, utcDateModified, isProtected
|
||||
FROM notes
|
||||
WHERE isDeleted = 0
|
||||
AND noteId IN (${noteIdStr})`);
|
||||
|
||||
Reference in New Issue
Block a user