Interface: LocalStorageCollectionConfig<TExplicit, TSchema, TFallback>#
Defined in: packages/db/src/local-storage.ts:61
Configuration interface for localStorage collection options
Remarks#
Type resolution follows a priority order:
- If you provide an explicit type via generic parameter, it will be used
- If no explicit type is provided but a schema is, the schema's output type will be inferred
- If neither explicit type nor schema is provided, the fallback type will be used
You should provide EITHER an explicit type OR a schema, but not both, as they would conflict.
Type Parameters#
• TExplicit = unknown
The explicit type of items in the collection (highest priority)
• TSchema extends StandardSchemaV1 = never
The schema type for validation and type inference (second priority)
• TFallback extends object = Record<string, unknown>
The fallback type if no explicit or schema type is provided
Properties#
getKey()#
getKey: (item) => string | number;
Defined in: packages/db/src/local-storage.ts:88
Parameters#
item#
Returns#
string | number
id?#
optional id: string;
Defined in: packages/db/src/local-storage.ts:86
Collection identifier (defaults to "local-collection:{storageKey}" if not provided)
onDelete()?#
optional onDelete: (params) => Promise<any>;
Defined in: packages/db/src/local-storage.ts:114
Optional asynchronous handler function called before a delete operation
Parameters#
params#
DeleteMutationFnParams<ResolveType<TExplicit, TSchema, TFallback>>
Object containing transaction and collection information
Returns#
Promise<any>
Promise resolving to any value
onInsert()?#
optional onInsert: (params) => Promise<any>;
Defined in: packages/db/src/local-storage.ts:96
Optional asynchronous handler function called before an insert operation
Parameters#
params#
InsertMutationFnParams<ResolveType<TExplicit, TSchema, TFallback>>
Object containing transaction and collection information
Returns#
Promise<any>
Promise resolving to any value
onUpdate()?#
optional onUpdate: (params) => Promise<any>;
Defined in: packages/db/src/local-storage.ts:105
Optional asynchronous handler function called before an update operation
Parameters#
params#
UpdateMutationFnParams<ResolveType<TExplicit, TSchema, TFallback>>
Object containing transaction and collection information
Returns#
Promise<any>
Promise resolving to any value
schema?#
optional schema: TSchema;
Defined in: packages/db/src/local-storage.ts:87
storage?#
optional storage: StorageApi;
Defined in: packages/db/src/local-storage.ts:75
Storage API to use (defaults to window.localStorage) Can be any object that implements the Storage interface (e.g., sessionStorage)
storageEventApi?#
optional storageEventApi: StorageEventApi;
Defined in: packages/db/src/local-storage.ts:81
Storage event API to use for cross-tab synchronization (defaults to window) Can be any object that implements addEventListener/removeEventListener for storage events
storageKey#
storageKey: string;
Defined in: packages/db/src/local-storage.ts:69
The key to use for storing the collection data in localStorage/sessionStorage
sync?#
optional sync: SyncConfig<ResolveType<TExplicit, TSchema, TFallback>, string | number>;
Defined in: packages/db/src/local-storage.ts:89