Creates an instance of IndexedDBStorageAdapter.
Note: The database connection is not opened until init() is called.
Configuration options including database name, version, and required object stores.
Removes all data from all object stores managed by this adapter instance within the database. Use with caution as this is destructive.
A promise that resolves when all specified object stores have been cleared.
Removes all items from a specific object store (collection).
The name of the object store to clear.
A promise that resolves when the collection is successfully cleared.
Deletes an item from the specified object store (collection) by its ID.
The name of the object store.
The ID (key) of the item to delete.
A promise that resolves when the deletion is successful.
Retrieves a single item by its ID from the specified object store (collection).
The expected type of the retrieved item.
The name of the object store.
The ID (key) of the item to retrieve.
A promise resolving to a copy of the item if found, or null otherwise.
Opens the IndexedDB database connection and ensures the required object stores
are created or updated based on the configured dbVersion.
This method MUST be called and awaited successfully before using other adapter methods.
It handles the onupgradeneeded event to create stores.
A promise that resolves when the database is successfully opened and ready, or rejects on error.
Queries items within a collection based on provided filter options.
Note: This implementation uses getAll() and performs filtering, sorting,
and limiting client-side. For large datasets, performance may be suboptimal.
A more advanced version would leverage IndexedDB indexes and cursors for
efficient querying directly within the database.
Supports basic exact-match filtering and single-key sorting.
The expected type of the items in the collection.
The name of the object store to query.
Options for filtering, sorting, skipping, and limiting results.
A promise resolving to an array of deep copies of the matching items.
Saves (creates or updates) an item in the specified object store (collection).
Assumes the object store uses 'id' as its keyPath. The id parameter provided
should match the id property within the data object.
Uses structuredClone to store a deep copy.
The type of the data being saved. Must have an 'id' property.
The name of the object store.
The unique ID of the item (should match data.id).
The data object to save. Must contain an id property matching the id parameter.
A promise that resolves when the data is successfully saved.
An implementation of the
StorageAdapterinterface that uses the browser's IndexedDB API for persistent, client-side storage.This adapter is suitable for web applications where conversation history, agent state, and observations need to persist across sessions.
Important: The
init()method must be called and awaited before performing any other database operations (get, set, delete, query).See