Skip to main content
Version: v10.0.0

DbOptions


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

Preview​

type DbOptions = DbNotation & { codecs?: readonly DbCodec[]; gcTime?: number; offline?: (boolean | DbOfflineOptions); persistence?: DbPersistenceOptions; state?: DehydratedDb; syncTimeout?: number; tabs?: (false | { channel?: DbChannel; locks?: DbLockManager }) };

Structure​

DbOptions
NameTypeDescription
where
Partial<Record<ComparisonOperator, (field: string, value: unknown) => AnyRequestPatch>>
codecs
readonly DbCodec[]

Value types to persist and dehydrate beyond Date , bigint , Map , Set , undefined , NaN and the infinities, which the db stores as type-tagged JSON on its own

gcTime
number

How long a loaded subset no query uses is kept. Defaults to five minutes, like the core cacheTime .

offline
boolean | DbOfflineOptions

Sends every write through the outbox, so writes made offline are replayed when the connection returns

persistence
DbPersistenceOptions

Persists rows, loaded subsets and the outbox

state
DehydratedDb

Rows and loaded subsets a server rendered with, from db.dehydrate() . They show at once and refetch when used.

syncTimeout
number

How long a write with onSuccess: &quot;sync&quot; waits for a sync event before it refetches

tabs
false | { channel?: DbChannel; locks?: DbLockManager }

How tabs agree on which one replays the outbox. Defaults to Web Locks and BroadcastChannel .

orderBy
(field: string, direction: SortDirection) => AnyRequestPatch