Skip to content

getServer

getServer<DataModel, TCollectionSlug, TPopulate, D>(args): Promise<GetReturn<TCollectionSlug, TPopulate, D>>

Defined in: packages/core/src/api/get/server.ts:60

Fetches a single document by its Id<TCollectionSlug>. Server-side only.

Pass populate to explicitly name the relationship fields to resolve (documented, recommended). Pass depth (with config) to automatically populate all relationship fields to N levels — internal use only.

Import from @vexcms/core/server. For the client-side version, import get from @vexcms/core/client.

DataModel extends GenericDataModel

Convex data model (inferred from args.ctx).

TCollectionSlug extends string

Collection slug, recovered from the Id brand.

TPopulate extends PopulateShape<TCollectionSlug> = Record<string, never>

Populate object.

D extends number = 0

Depth literal (0 = none).

GetServerArgs<DataModel, TCollectionSlug, TPopulate, D>

{ ctx, id, populate? } or { ctx, id, depth, config }.

Promise<GetReturn<TCollectionSlug, TPopulate, D>>

Promise resolving to the doc or null if not found.

import { get } from "@vexcms/core/server";
export const post = query({
args: { id: v.id("posts") },
handler: (ctx, args) => get({ ctx, id: args.id, populate: { author: true } }),
});