Skip to content

FindServerArgs

Defined in: packages/core/src/api/find/server.ts:49

Server-side args for find. Extends GenericQueryServerParams to inherit ctx, populate, depth, and config (with their mutual-exclusion constraints). All query-chain options map to ctx.db.query() equivalents applied in order: withIndexorderfiltertake.

DataModel extends GenericDataModel

The Convex data model (inferred from ctx).

TCollectionSlug extends CollectionSlug

Collection slug.

TPopulate extends PopulateShape<TCollectionSlug>

Populate object.

D extends number = 0

Depth literal (0 = no depth, default).

optional access?: AccessCallOptions<QueryCallAction>

Defined in: packages/core/src/api/types.ts:216

Per-call access overrides.

AccessCallOptions

GenericQueryServerParams.access


optional auth?: VexApiAuth

Defined in: packages/core/src/api/types.ts:223

The auth config of the current user making the query.

{ user: {...}, organization: {...} }

GenericQueryServerParams.auth


collection: TCollectionSlug

Defined in: packages/core/src/api/find/server.ts:56

The collection to query — must match a registered collection slug.


optional config?: [TPopulate] extends [Record<string, never>] ? VexConfig : never

Defined in: packages/core/src/api/types.ts:241

The resolved VexConfig. Required alongside depth; passed from the queryApi factory closure so the Convex handler has schema info.

GenericQueryServerParams.config


ctx: GenericQueryCtx<DataModel>

Defined in: packages/core/src/api/types.ts:225

Discriminator: server args MUST supply a Convex query context.

GenericQueryServerParams.ctx


optional depth?: [TPopulate] extends [Record<string, never>] ? D : never

Defined in: packages/core/src/api/types.ts:236

Auto-populate all relationship fields to this many levels. Becomes never when TPopulate is non-empty. Use populate for consumer-facing code; this is an internal escape hatch for CollectionListView.

GenericQueryServerParams.depth


optional filter?: (q) => ExpressionOrValue<boolean>

Defined in: packages/core/src/api/find/server.ts:83

Filter predicate applied after index narrowing. Equivalent to .filter(q => q.eq(q.field("published"), true)) on the Convex query.

Prefer withIndex for performance — filter scans every document in the range and is O(n). Use filter for secondary conditions that can’t be expressed as index equality ranges.

FilterBuilder<NamedTableInfo<DataModel, TCollectionSlug extends TableNamesInDataModel<DataModel> ? TCollectionSlug : never>>

ExpressionOrValue<boolean>

find({ ctx, collection: "posts", filter: q => q.eq(q.field("published"), true) })

optional limit?: number

Defined in: packages/core/src/api/find/server.ts:62

Maximum number of documents to return. Defaults to 100. Applied as the terminal .take(n) on the Convex query.


optional order?: "asc" | "desc"

Defined in: packages/core/src/api/find/server.ts:68

Result ordering. Equivalent to .order("asc" | "desc") on the Convex query. Defaults to "asc" (insertion order).


optional paginationOpts?: PaginationOptions

Defined in: packages/core/src/api/find/server.ts:127

Pagination options. When provided, the function returns a PaginationResult with { page, continueCursor, isDone } instead of a plain array.

Uses Convex’s native .paginate(opts) API under the hood.


optional populate?: [D] extends [0] ? TPopulate : never

Defined in: packages/core/src/api/types.ts:230

Recursive populate object, type-narrowed against RelationshipKeysOf<TCollectionSlug>. Mutually exclusive with depth — becomes never when D ≠ 0.

GenericQueryServerParams.populate


optional withIndex?: TCollectionSlug extends TableNamesInDataModel<DataModel> ? object : never

Defined in: packages/core/src/api/find/server.ts:105

Index to use for the query, with an optional equality/range constraint. Equivalent to .withIndex(name, range?) on the Convex query.

Using an index is strongly preferred over filter for performance.

find({ ctx, collection: "posts", withIndex: { name: "by_slug", range: q => q.eq("slug", "hello") } })
find({ ctx, collection: "posts", withIndex: { name: "by_score", range: q => q.gte("score", 50) } })
find({ ctx, collection: "posts", withIndex: { name: "by_publishedAt" } })