Defined in: packages/query-db-collection/src/query.ts:154
Utility methods available on Query Collections for direct writes and manual operations. Direct writes bypass the normal query/mutation flow and write directly to the synced data store.
TItem extends object = Record<string, unknown>
The type of items stored in the collection
TKey extends string | number = string | number
The type of the item keys
TInsertInput extends object = TItem
The type accepted for insert operations
TError = unknown
The type of errors that can occur during queries
[key: string]: any
[key: string]: any
clearError: () => Promise<void>;
clearError: () => Promise<void>;
Defined in: packages/query-db-collection/src/query.ts:199
Clear the error state and trigger a refetch of the query
Promise<void>
Promise that resolves when the refetch completes successfully
Error if the refetch fails
dataUpdatedAt: number;
dataUpdatedAt: number;
Defined in: packages/query-db-collection/src/query.ts:190
Get timestamp of last successful data update (in milliseconds)
errorCount: number;
errorCount: number;
Defined in: packages/query-db-collection/src/query.ts:182
Get the number of consecutive sync failures. Incremented only when query fails completely (not per retry attempt); reset on success.
fetchStatus: "idle" | "fetching" | "paused";
fetchStatus: "idle" | "fetching" | "paused";
Defined in: packages/query-db-collection/src/query.ts:192
Get current fetch status
isError: boolean;
isError: boolean;
Defined in: packages/query-db-collection/src/query.ts:177
Check if the collection is in an error state
isFetching: boolean;
isFetching: boolean;
Defined in: packages/query-db-collection/src/query.ts:184
Check if query is currently fetching (initial or background)
isLoading: boolean;
isLoading: boolean;
Defined in: packages/query-db-collection/src/query.ts:188
Check if query is loading for the first time (no data yet)
isRefetching: boolean;
isRefetching: boolean;
Defined in: packages/query-db-collection/src/query.ts:186
Check if query is refetching in background (not initial fetch)
lastError: TError | undefined;
lastError: TError | undefined;
Defined in: packages/query-db-collection/src/query.ts:175
Get the last error encountered by the query (if any); reset on success
refetch: RefetchFn;
refetch: RefetchFn;
Defined in: packages/query-db-collection/src/query.ts:161
Manually trigger a refetch of the query
writeBatch: (callback) => void;
writeBatch: (callback) => void;
Defined in: packages/query-db-collection/src/query.ts:171
Execute multiple write operations as a single atomic batch to the synced data store
() => void
void
writeDelete: (keys) => void;
writeDelete: (keys) => void;
Defined in: packages/query-db-collection/src/query.ts:167
Delete one or more items directly from the synced data store without triggering a query refetch or optimistic update
TKey | TKey[]
void
writeInsert: (data) => void;
writeInsert: (data) => void;
Defined in: packages/query-db-collection/src/query.ts:163
Insert one or more items directly into the synced data store without triggering a query refetch or optimistic update
TInsertInput | TInsertInput[]
void
writeUpdate: (updates) => void;
writeUpdate: (updates) => void;
Defined in: packages/query-db-collection/src/query.ts:165
Update one or more items directly in the synced data store without triggering a query refetch or optimistic update
Partial<TItem> | Partial<TItem>[]
void
writeUpsert: (data) => void;
writeUpsert: (data) => void;
Defined in: packages/query-db-collection/src/query.ts:169
Insert or update one or more items directly in the synced data store without triggering a query refetch or optimistic update
Partial<TItem> | Partial<TItem>[]
void
