electricCollectionOptions

Function: electricCollectionOptions()

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()

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

Parameters

item

ResolveType

Returns

string | number

id?

optional id: string;
optional id: string;

All standard Collection configuration properties

onDelete

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

onInsert

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

onUpdate

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

schema?

optional schema: TSchema;
optional schema: TSchema;

sync

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

utils

utils: object;
utils: object;

utils.awaitTxId

awaitTxId: AwaitTxIdFn;
awaitTxId: AwaitTxIdFn;
Our Partners
Code Rabbit
Cloudflare
Electric
Prisma
Subscribe to Bytes

Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.

Bytes

No spam. Unsubscribe at any time.

Subscribe to Bytes

Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.

Bytes

No spam. Unsubscribe at any time.