electricCollectionOptions

Function: electricCollectionOptions()

ts
function electricCollectionOptions<TExplicit, TSchema, TFallback>(config): object
function electricCollectionOptions<TExplicit, TSchema, TFallback>(config): object

Defined in: packages/electric-db-collection/src/electric.ts:285

Creates Electric collection options for use with a standard Collection

Type Parameters

TExplicit extends Row<unknown> = Row<unknown>

The explicit type of items in the collection (highest priority)

TSchema extends StandardSchemaV1<unknown, unknown> = never

The schema type for validation and type inference (second priority)

TFallback extends Row<unknown> = Row<unknown>

The fallback type if no explicit or schema type is provided

Parameters

config

ElectricCollectionConfig<TExplicit, TSchema, TFallback>

Configuration options for the Electric collection

Returns

object

Collection options with utilities

getKey()

ts
getKey: (item) => string | number;
getKey: (item) => string | number;

Parameters

item

ResolveType

Returns

string | number

id?

ts
optional id: string;
optional id: string;

All standard Collection configuration properties

onDelete

ts
onDelete: 
  | undefined
  | (params) => Promise<{
  txid: number | number[];
 }> = wrappedOnDelete;
onDelete: 
  | undefined
  | (params) => Promise<{
  txid: number | number[];
 }> = wrappedOnDelete;

onInsert

ts
onInsert: 
  | undefined
  | (params) => Promise<{
  txid: number | number[];
 }> = wrappedOnInsert;
onInsert: 
  | undefined
  | (params) => Promise<{
  txid: number | number[];
 }> = wrappedOnInsert;

onUpdate

ts
onUpdate: 
  | undefined
  | (params) => Promise<{
  txid: number | number[];
 }> = wrappedOnUpdate;
onUpdate: 
  | undefined
  | (params) => Promise<{
  txid: number | number[];
 }> = wrappedOnUpdate;

schema?

ts
optional schema: TSchema;
optional schema: TSchema;

sync

ts
sync: SyncConfig<ResolveType<TExplicit, TSchema, TFallback>, string | number>;
sync: SyncConfig<ResolveType<TExplicit, TSchema, TFallback>, string | number>;

utils

ts
utils: object;
utils: object;

utils.awaitTxId

ts
awaitTxId: AwaitTxIdFn;
awaitTxId: AwaitTxIdFn;