Notes/src/becca/entities/bblob.ts

44 lines
1.1 KiB
TypeScript
Raw Normal View History

import AbstractBeccaEntity from "./abstract_becca_entity.js";
import type { BlobRow } from "./rows.js";
2024-02-17 01:06:07 +02:00
2024-02-18 20:29:23 +02:00
// TODO: Why this does not extend the abstract becca?
class BBlob extends AbstractBeccaEntity<BBlob> {
2025-01-09 18:07:02 +02:00
static get entityName() {
return "blobs";
}
static get primaryKeyName() {
return "blobId";
}
static get hashedProperties() {
return ["blobId", "content"];
}
2023-06-28 21:05:31 +02:00
content!: string | Buffer;
contentLength!: number;
2024-02-17 01:06:07 +02:00
constructor(row: BlobRow) {
super();
this.updateFromRow(row);
}
updateFromRow(row: BlobRow): void {
2023-05-05 16:37:39 +02:00
this.blobId = row.blobId;
this.content = row.content;
this.contentLength = row.contentLength;
this.dateModified = row.dateModified;
this.utcDateModified = row.utcDateModified;
}
getPojo() {
return {
blobId: this.blobId,
content: this.content || null,
2023-05-05 16:37:39 +02:00
contentLength: this.contentLength,
dateModified: this.dateModified,
utcDateModified: this.utcDateModified
};
}
}
export default BBlob;