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.
Type Parameters
Section titled “Type Parameters”DataModel
Section titled “DataModel”DataModel extends GenericDataModel
Convex data model (inferred from args.ctx).
TCollectionSlug
Section titled “TCollectionSlug”TCollectionSlug extends string
Collection slug, recovered from the Id brand.
TPopulate
Section titled “TPopulate”TPopulate extends PopulateShape<TCollectionSlug> = Record<string, never>
Populate object.
D extends number = 0
Depth literal (0 = none).
Parameters
Section titled “Parameters”GetServerArgs<DataModel, TCollectionSlug, TPopulate, D>
{ ctx, id, populate? } or { ctx, id, depth, config }.
Returns
Section titled “Returns”Promise<GetReturn<TCollectionSlug, TPopulate, D>>
Promise resolving to the doc or null if not found.
Example
Section titled “Example”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 } }),});