Skip to content

vexGetQuery

vexGetQuery<TCollectionSlug, TPopulate, D>(client, args): Promise<GetReturn<TCollectionSlug, TPopulate, D>>

Defined in: packages/core/src/collections/api/networkQuery.ts:360

Fetches a single document by ID via a direct network call.

TCollectionSlug extends string

TPopulate extends ContainerPopulateShape<PopulateMapFor<TCollectionSlug>> = Record<string, never>

D extends number = 0

VexNetworkQueryClient

Any client exposing query(ref, args).

GetClientArgs<TCollectionSlug, TPopulate, D>

{ id, collection, populate?, depth? }.

Promise<GetReturn<TCollectionSlug, TPopulate, D>>

The document, or null when no document matches id.

vexFindQuery for the client contract and why the funcRef cast is sound.

const post = await vexGetQuery(vex, { id: postId, collection: "posts" });
// ^? Post | null