@idpass/data-collect-core / IndexedDbAttachmentStorageAdapter
Class: IndexedDbAttachmentStorageAdapter
Defined in: storage/IndexedDbAttachmentStorageAdapter.ts:35
IndexedDB implementation of the AttachmentStore for browser-based attachment persistence.
Uses two object stores:
attachment_metadata: Stores AttachmentMetadata objects with indexes on entityGuid, tenantId, and syncStatus for efficient querying.attachment_data: Stores binary data (ArrayBuffer) keyed by attachment GUID.
Supports multi-tenant isolation via tenant ID prefixed database names.
Implements
Constructors
Constructor
new IndexedDbAttachmentStorageAdapter(
tenantId?):IndexedDbAttachmentStorageAdapter
Defined in: storage/IndexedDbAttachmentStorageAdapter.ts:47
Creates a new IndexedDbAttachmentStorageAdapter instance.
Parameters
tenantId?
string = ""
Optional tenant identifier for multi-tenant isolation. When provided, creates a separate database prefixed with tenant ID.
Returns
IndexedDbAttachmentStorageAdapter
Properties
tenantId
readonlytenantId:string=""
Defined in: storage/IndexedDbAttachmentStorageAdapter.ts:47
Optional tenant identifier for multi-tenant isolation. When provided, creates a separate database prefixed with tenant ID.
Methods
initialize()
initialize():
Promise<void>
Defined in: storage/IndexedDbAttachmentStorageAdapter.ts:56
Initializes the IndexedDB database with required object stores and indexes.
Returns
Promise<void>
saveAttachment()
saveAttachment(
metadata,data):Promise<void>
Defined in: storage/IndexedDbAttachmentStorageAdapter.ts:86
Saves attachment metadata and binary data.
Parameters
metadata
data
ArrayBuffer
Returns
Promise<void>
Implementation of
AttachmentStore.saveAttachment
getAttachment()
getAttachment(
guid):Promise<{metadata:AttachmentMetadata;data:ArrayBuffer; } |null>
Defined in: storage/IndexedDbAttachmentStorageAdapter.ts:113
Gets attachment metadata and binary data by GUID.
Parameters
guid
string
Returns
Promise<{ metadata: AttachmentMetadata; data: ArrayBuffer; } | null>
Implementation of
getAttachmentMetadata()
getAttachmentMetadata(
guid):Promise<AttachmentMetadata|null>
Defined in: storage/IndexedDbAttachmentStorageAdapter.ts:141
Gets only the metadata for an attachment (without loading binary data).
Parameters
guid
string
Returns
Promise<AttachmentMetadata | null>
Implementation of
AttachmentStore.getAttachmentMetadata
listAttachments()
listAttachments(
entityGuid):Promise<AttachmentMetadata[]>
Defined in: storage/IndexedDbAttachmentStorageAdapter.ts:162
Lists all attachments for a specific entity.
Parameters
entityGuid
string
Returns
Promise<AttachmentMetadata[]>
Implementation of
AttachmentStore.listAttachments
deleteAttachment()
deleteAttachment(
guid):Promise<void>
Defined in: storage/IndexedDbAttachmentStorageAdapter.ts:184
Deletes an attachment and its binary data.
Parameters
guid
string
Returns
Promise<void>
Implementation of
AttachmentStore.deleteAttachment
getPendingAttachments()
getPendingAttachments(
tenantId):Promise<AttachmentMetadata[]>
Defined in: storage/IndexedDbAttachmentStorageAdapter.ts:211
Gets all attachments with 'pending' sync status for a tenant.
Parameters
tenantId
string
Returns
Promise<AttachmentMetadata[]>
Implementation of
AttachmentStore.getPendingAttachments
updateSyncStatus()
updateSyncStatus(
guid,status):Promise<void>
Defined in: storage/IndexedDbAttachmentStorageAdapter.ts:233
Updates the sync status of an attachment.
Parameters
guid
string
status
"pending" | "uploaded" | "failed"
Returns
Promise<void>
Implementation of
AttachmentStore.updateSyncStatus
closeConnection()
closeConnection():
Promise<void>
Defined in: storage/IndexedDbAttachmentStorageAdapter.ts:270
Closes the IndexedDB connection.
Returns
Promise<void>
clearStore()
clearStore():
Promise<void>
Defined in: storage/IndexedDbAttachmentStorageAdapter.ts:280
Clears all data from both metadata and data stores.
Returns
Promise<void>