API reference
Every public class, method, and event in @codexo/exojs. Generated from source.
classIndexedDbDatabase
Database implementation backed by the browser's IndexedDB API. Each object store is created with a `keyPath` of `"name"`, so records are stored as `{ name, data }` objects. The store names are fixed at construction: this is a database with a declared schema, which is what makes it suitable for structured application data such as save games, and unsuitable for a cache whose namespaces are only known at runtime - IndexedDbStore exists for that. Schema migrations run in two modes: - **Default** - the constructor-supplied `storeNames` are diffed against the existing stores and object stores added or deleted accordingly. - **Explicit** - a `migrations` map keyed by target version runs the corresponding callback for each version between `oldVersion` and `newVersion`. A callback returning `false` aborts the upgrade, leaving the database at its previous version. A write resolves only once its transaction has committed, so awaiting a write and then reading it back cannot miss. Every failure rejects with an AssetCacheError that names the failed AssetCacheOperation, the store and key involved, and carries the originating `DOMException` as `cause` - so a `QuotaExceededError` is distinguishable from a transaction or schema failure without parsing message text. That holds for the parts of the IndexedDB API that throw synchronously instead of failing a request just as it does for a failed request.
import { IndexedDbDatabase } from '@codexo/exojs'Database implementation backed by the browser's IndexedDB API.
Each object store is created with a `keyPath` of `"name"`, so records are stored as `{ name, data }` objects. The store names are fixed at construction: this is a database with a declared schema, which is what makes it suitable for structured application data such as save games, and unsuitable for a cache whose namespaces are only known at runtime - IndexedDbStore exists for that.
Schema migrations run in two modes: - **Default** - the constructor-supplied `storeNames` are diffed against the existing stores and object stores added or deleted accordingly. - **Explicit** - a `migrations` map keyed by target version runs the corresponding callback for each version between `oldVersion` and `newVersion`. A callback returning `false` aborts the upgrade, leaving the database at its previous version.
A write resolves only once its transaction has committed, so awaiting a write and then reading it back cannot miss.
Every failure rejects with an AssetCacheError that names the failed AssetCacheOperation, the store and key involved, and carries the originating `DOMException` as `cause` - so a `QuotaExceededError` is distinguishable from a transaction or schema failure without parsing message text. That holds for the parts of the IndexedDB API that throw synchronously instead of failing a request just as it does for a failed request.
new(name: string, version: number, storeNames: readonly string[], migrations?: Record<number, (db: IDBDatabase, transaction: IDBTransaction) => boolean>): IndexedDbDatabaseclearStorage(type: string): Promise<boolean>connect(): Promise<boolean>delete(type: string, name: string): Promise<boolean>deleteStorage(): Promise<boolean>destroy(): voiddisconnect(): Promise<boolean>load(type: string, name: string): Promise<T | null>save(type: string, name: string, data: unknown): Promise<void>name: stringversion: numberconnected: boolean