function indexedDBCollectionOptions<T, TKey>(config): CollectionConfig<InferSchemaOutput<T>, TKey, T, IndexedDBCollectionUtils<InferSchemaOutput<T>, InferSchemaInput<T>>> & object;Defined in: packages/indexeddb-db-collection/src/indexeddb.ts:406
Creates IndexedDB collection options for use with a standard Collection. This provides persistent local storage with cross-tab synchronization.
IMPORTANT: You must first create the database with createIndexedDB() and pass the instance to this function. This ensures all stores are created upfront in a single upgrade transaction.
T extends StandardSchemaV1<unknown, unknown>
TKey extends string | number = string | number
IndexedDBCollectionConfig<InferSchemaOutput<T>, T, TKey> & object
CollectionConfig<InferSchemaOutput<T>, TKey, T, IndexedDBCollectionUtils<InferSchemaOutput<T>, InferSchemaInput<T>>> & object
// Step 1: Create database with all stores
const db = await createIndexedDB({
name: 'myApp',
version: 1,
stores: ['todos', 'users'],
})
// Step 2: Create collections using the shared database
const todosCollection = createCollection(
indexedDBCollectionOptions({
db,
name: 'todos',
schema: todoSchema,
getKey: (item: { id: string }) => item.id,
})
)// Without schema (explicit type)
const todosCollection = createCollection(
indexedDBCollectionOptions<Todo>({
db,
name: 'todos',
getKey: (item: { id: string }) => item.id,
})
)function indexedDBCollectionOptions<T, TKey>(config): CollectionConfig<T, TKey, never, IndexedDBCollectionUtils<T, T>> & object;Defined in: packages/indexeddb-db-collection/src/indexeddb.ts:424
Creates IndexedDB collection options for use with a standard Collection. This provides persistent local storage with cross-tab synchronization.
IMPORTANT: You must first create the database with createIndexedDB() and pass the instance to this function. This ensures all stores are created upfront in a single upgrade transaction.
T extends object
TKey extends string | number = string | number
IndexedDBCollectionConfig<T, never, TKey> & object
CollectionConfig<T, TKey, never, IndexedDBCollectionUtils<T, T>> & object
// Step 1: Create database with all stores
const db = await createIndexedDB({
name: 'myApp',
version: 1,
stores: ['todos', 'users'],
})
// Step 2: Create collections using the shared database
const todosCollection = createCollection(
indexedDBCollectionOptions({
db,
name: 'todos',
schema: todoSchema,
getKey: (item: { id: string }) => item.id,
})
)// Without schema (explicit type)
const todosCollection = createCollection(
indexedDBCollectionOptions<Todo>({
db,
name: 'todos',
getKey: (item: { id: string }) => item.id,
})
)