WIP blobs

This commit is contained in:
zadam
2023-03-16 11:02:07 +01:00
parent 5a8e216dec
commit e16bedfab4
30 changed files with 65 additions and 102 deletions

View File

@@ -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}'`);
}
}

View File

@@ -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})`);