Skip to content

IndexedDb.ts

Browser IndexedDB primitives and key schemas for Effect applications.

This module is the low-level bridge used by the platform-browser IndexedDB integration. It provides an IndexedDb service around the browser indexedDB factory and IDBKeyRange constructor, a layerWindow layer for wiring those primitives from window, and schemas for the key shapes accepted by IndexedDB object stores and indexes.

Since v4.0.0



Layer that provides IndexedDb from window.indexedDB and window.IDBKeyRange, failing with a config error when they are unavailable.

Signature

declare const layerWindow: Layer.Layer<IndexedDb, never, never>

Source

Since v4.0.0

Creates an IndexedDb service from an IDBFactory and IDBKeyRange constructor.

Signature

declare const make: (impl: Omit<IndexedDb, typeof TypeId>) => IndexedDb

Source

Since v4.0.0

Service interface that provides the browser indexedDB factory and IDBKeyRange constructor.

Signature

export interface IndexedDb {
readonly [TypeId]: typeof TypeId
readonly indexedDB: globalThis.IDBFactory
readonly IDBKeyRange: typeof globalThis.IDBKeyRange
}

Source

Since v4.0.0

Schema for auto-incremented IndexedDB keys, accepting integers from 1 through 2 ** 53.

When to use

Use when you need to define numeric key-path fields for IndexedDbTable definitions that use IndexedDB auto-increment keys.

Details

The schema accepts integer values from 1 through 2 ** 53, matching the range used for generated IndexedDB auto-increment keys.

See

  • IDBValidKey for the broader IndexedDB key schema

Signature

declare const AutoIncrement: Schema.Int

Source

Since v4.0.0

Schema for IndexedDB keys: strings, non-NaN numbers, valid dates, buffer sources, or arrays of those flat key values.

Signature

declare const IDBValidKey: Schema.Union<
readonly [
Schema.Union<readonly [Schema.String, Schema.Number, Schema.DateValid, Schema.declare<BufferSource, unknown>]>,
Schema.$Array<
Schema.Union<readonly [Schema.String, Schema.Number, Schema.DateValid, Schema.declare<BufferSource, unknown>]>
>
]
>

Source

Since v4.0.0

Service tag for browser IndexedDB primitives.

Signature

declare const IndexedDb: Context.Service<IndexedDb, IndexedDb>

Source

Since v4.0.0