AttachmentContext
Experimental Alpha
AttachmentContext provides database operations for managing attachment records.
Provides methods to query, insert, update, and delete attachment records with proper transaction management through PowerSync.
Constructors
new AttachmentContext()
new AttachmentContext(
db,
tableName,
logger,
archivedCacheLimit): AttachmentContext
Alpha
Parameters
| Parameter | Type | Description |
|---|---|---|
db | AbstractPowerSyncDatabase | PowerSync database instance |
tableName | undefined | string | Name of the table storing attachment records. Default: 'attachments' |
logger | ILogger | Logger instance for diagnostic output |
archivedCacheLimit | number | - |
Returns
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
archivedCacheLimit | readonly | number | Alpha Maximum number of archived attachments to keep before cleanup |
db | readonly | AbstractPowerSyncDatabase | Alpha PowerSync database instance for executing queries |
logger | readonly | ILogger | Alpha Logger instance for diagnostic information |
tableName | readonly | string | Alpha Name of the database table storing attachment records |
Methods
clearQueue()
clearQueue(): Promise<void>
Alpha Experimental
Returns
Promise<void>
deleteArchivedAttachments()
deleteArchivedAttachments(callback?): Promise<boolean>
Alpha Experimental
Parameters
| Parameter | Type |
|---|---|
callback? | (attachments) => Promise<void> |
Returns
Promise<boolean>
deleteAttachment()
deleteAttachment(attachmentId): Promise<void>
Alpha
Parameters
| Parameter | Type | Description |
|---|---|---|
attachmentId | string | Unique identifier of the attachment to delete |
Returns
Promise<void>
getActiveAttachments()
getActiveAttachments(): Promise<AttachmentRecord[]>
Alpha
Returns
Promise<AttachmentRecord[]>
Promise resolving to an array of active attachment records
getArchivedAttachments()
getArchivedAttachments(): Promise<AttachmentRecord[]>
Alpha
Returns
Promise<AttachmentRecord[]>
Promise resolving to an array of archived attachment records
getAttachment()
getAttachment(id): Promise<undefined | AttachmentRecord>
Alpha Experimental
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
Promise<undefined | AttachmentRecord>
getAttachments()
getAttachments(): Promise<AttachmentRecord[]>
Alpha
Returns
Promise<AttachmentRecord[]>
Promise resolving to an array of all attachment records
saveAttachments()
saveAttachments(attachments): Promise<void>
Alpha
Parameters
| Parameter | Type | Description |
|---|---|---|
attachments | AttachmentRecord[] | Array of attachment records to save |
Returns
Promise<void>
upsertAttachment()
upsertAttachment(attachment, context): Promise<void>
Alpha
Parameters
| Parameter | Type | Description |
|---|---|---|
attachment | AttachmentRecord | The attachment record to upsert |
context | Transaction | Active database transaction context |
Returns
Promise<void>