IndexedDbVersion
Typed IndexedDB schema version definitions.
This module represents one logical IndexedDB database version as a non-empty set of IndexedDbTable definitions. Versions are consumed by IndexedDbDatabase.make and .add to type query builders and migration transactions, so applications can describe the tables available after initialization or after each schema upgrade.
Use an IndexedDbVersion when defining the initial stores for a browser database, adding or removing object stores, changing indexes, or moving data between differently shaped table schemas. The version value is a typed description of the target schema; creating and deleting object stores or indexes still happens explicitly inside the corresponding IndexedDbDatabase migration callback.
IndexedDB versioning is ordered by the migration chain rather than by a number stored here. Each .add step becomes the next browser database version, and only migrations after the browser's current version are run. Include every table that should be queryable in each target version, avoid duplicate table names, and remember that key-path or auto-increment changes usually require creating a new object store and copying data during the upgrade transaction.
Constructors
Models
Type-erased shape of an IndexedDbVersion.
Signature
interface Any {
readonly "~@effect/platform-browser/IndexedDbVersion": "~@effect/platform-browser/IndexedDbVersion";
}AnyWithProps type
Type-erased IndexedDbVersion retaining version properties with broad table types.
Signature
type AnyWithProps = IndexedDbVersion<IndexedDbTable.AnyWithProps>;IndexedDbVersion interface
Typed IndexedDB version definition containing the tables available in that schema version.
Signature
interface IndexedDbVersion<out Tables extends IndexedDbTable.AnyWithProps> extends Pipeable {
constructor(_: never);
readonly "~@effect/platform-browser/IndexedDbVersion": "~@effect/platform-browser/IndexedDbVersion";
readonly tables: ReadonlyMap<string, Tables>;
}Utility Types
SchemaWithName type
Extracts the schema for a named table within an IndexedDbVersion.
Signature
type SchemaWithName<Db extends Any, TableName extends string> = IndexedDbTable.TableSchema<
IndexedDbTable.WithName<Tables<Db>, TableName>
>;Extracts the table union from an IndexedDbVersion.
Signature
type Tables<Db extends Any> = Db extends IndexedDbVersion<infer _Tables> ? _Tables : never;TableWithName type
Selects a table by name from an IndexedDbVersion.
Signature
type TableWithName<Db extends Any, TableName extends string> = IndexedDbTable.WithName<
Tables<Db>,
TableName
>;
Creates an
IndexedDbVersionfrom one or more table definitions.When to use
Use when you need a typed description of the target IndexedDB schema that a database migration will materialize.
Details
The returned version exposes a
tablesmap keyed by each table'stableName, and its type is the union of the supplied table definitions.Gotchas
This constructor only describes the target schema; object stores and indexes still need to be created in the corresponding
IndexedDbDatabasemigration. Duplicate table names are not rejected, and the runtime map keeps the later table for a repeated key.See
IndexedDbTable.make for creating table definitions consumed by this constructor