AttachmentStorage
Interface: AttachmentStorage
Abstract interface for attachment storage backends.
All storage implementations must implement this interface to ensure compatibility with the mock server's attachment handling.
Methods
clear()
clear(): Promise<number>Clear all stored attachments. Use with caution - this deletes all data.
Returns
Promise<number>
Number of attachments deleted
delete()
delete(id): Promise<boolean>Delete an attachment by ID.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The attachment's snowflake ID |
Returns
Promise<boolean>
true if deleted, false if not found
deleteForMessage()
deleteForMessage(messageId): Promise<number>Delete all attachments for a specific message.
Parameters
| Parameter | Type | Description |
|---|---|---|
messageId | string | The message's snowflake ID |
Returns
Promise<number>
Number of attachments deleted
get()
get(id): Promise<undefined | StoredAttachment>Retrieve an attachment by ID.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The attachment's snowflake ID |
Returns
Promise<undefined | StoredAttachment>
The stored attachment or undefined if not found
getForMessage()
getForMessage(messageId): Promise<StoredAttachment[]>Get all attachments for a specific message.
Parameters
| Parameter | Type | Description |
|---|---|---|
messageId | string | The message's snowflake ID |
Returns
Promise<StoredAttachment[]>
Array of stored attachments belonging to the message
getStats()
getStats(): Promise<StorageStats>Get storage statistics.
Returns
Promise<StorageStats>
Current storage metrics
store()
store(attachment): Promise<void>Store an attachment.
Parameters
| Parameter | Type | Description |
|---|---|---|
attachment | StoredAttachment | The attachment data to store |
Returns
Promise<void>
Promise that resolves when storage is complete
