Skip to main content
Version: v10.0.0

SyncChangesOptions


Import
import { SyncChangesOptions } from "@hyper-fetch/db"

Preview​

type SyncChangesOptions<Row,KeyField,Listener,Mapped> = {
byKey?: (key: NonNullable<Row[KeyField]>) => ListenerPatch;
changes: (event: SyncEvent<Listener>) => { delete: readonly NonNullable<Row[KeyField]>[]; refetch?: readonly NonNullable<Row[KeyField]>[]; upsert: readonly Mapped[] };
notation?: (conditions: readonly ComparisonNode[]) => ListenerPatch;
resumes?: boolean;
}

Structure​

SyncChangesOptions
NameTypeDescription
resumes
boolean

The adapter resumes the subscription from its last event id after a reconnect, so nothing is missed

byKey
(key: NonNullable<Row[KeyField]>) => ListenerPatch

Listener params that keep one row read by key live, such as a listener on one document

changes
(event: SyncEvent<Listener>) => { delete: readonly NonNullable<Row[KeyField]>[]; refetch?: readonly NonNullable<Row[KeyField]>[]; upsert: readonly Mapped[] }

Reads the complete rows to write and the keys to delete from one event

notation
(conditions: readonly ComparisonNode[]) => ListenerPatch

Turns a subset's sent conditions into listener params, so the sync covers every subset