Skip to main content

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

ParameterTypeDescription
dbAbstractPowerSyncDatabasePowerSync database instance
tableNameundefined | stringName of the table storing attachment records. Default: 'attachments'
loggerILoggerLogger instance for diagnostic output
archivedCacheLimitnumber-

Returns

AttachmentContext

Properties

PropertyModifierTypeDescription
archivedCacheLimitreadonlynumberAlpha Maximum number of archived attachments to keep before cleanup
dbreadonlyAbstractPowerSyncDatabaseAlpha PowerSync database instance for executing queries
loggerreadonlyILoggerAlpha Logger instance for diagnostic information
tableNamereadonlystringAlpha 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

ParameterType
callback?(attachments) => Promise<void>

Returns

Promise<boolean>


deleteAttachment()

deleteAttachment(attachmentId): Promise<void>

Alpha

Parameters

ParameterTypeDescription
attachmentIdstringUnique 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

ParameterType
idstring

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

ParameterTypeDescription
attachmentsAttachmentRecord[]Array of attachment records to save

Returns

Promise<void>


upsertAttachment()

upsertAttachment(attachment, context): Promise<void>

Alpha

Parameters

ParameterTypeDescription
attachmentAttachmentRecordThe attachment record to upsert
contextTransactionActive database transaction context

Returns

Promise<void>