FindServerArgs
Defined in: packages/core/src/collections/api/find/server.ts:57
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: withIndex → order → filter → take.
Extends
Section titled “Extends”GenericQueryServerParams<DataModel,TCollectionSlug,TPopulate,D>
Type Parameters
Section titled “Type Parameters”DataModel
Section titled “DataModel”DataModel extends GenericDataModel
The Convex data model (inferred from ctx).
TCollectionSlug
Section titled “TCollectionSlug”TCollectionSlug extends CollectionSlug
Collection slug.
TPopulate
Section titled “TPopulate”TPopulate extends PopulateShape<TCollectionSlug>
Populate object.
D extends number = 0
Depth literal (0 = no depth, default).
Properties
Section titled “Properties”access?
Section titled “access?”
optionalaccess?:AccessCallOptions<QueryCallAction>
Defined in: packages/core/src/collections/api/types.ts:143
Per-call access overrides.
Inherited from
Section titled “Inherited from”GenericQueryServerParams.access
optionalauth?:VexApiAuth
Defined in: packages/core/src/collections/api/types.ts:150
The auth config of the current user making the query.
Example
Section titled “Example”{ user: {...}, organization: {...} }Inherited from
Section titled “Inherited from”collection
Section titled “collection”collection:
TCollectionSlug
Defined in: packages/core/src/collections/api/find/server.ts:64
The collection to query — must match a registered collection slug.
config?
Section titled “config?”
optionalconfig?: [TPopulate] extends [Record<string,never>] ?VexConfig:never
Defined in: packages/core/src/collections/api/types.ts:168
The resolved VexConfig. Required alongside depth; passed
from the queryApi factory closure so the Convex handler has schema info.
Inherited from
Section titled “Inherited from”GenericQueryServerParams.config
ctx:
GenericQueryCtx<DataModel>
Defined in: packages/core/src/collections/api/types.ts:152
Discriminator: server args MUST supply a Convex query context.
Inherited from
Section titled “Inherited from”depth?
Section titled “depth?”
optionaldepth?: [TPopulate] extends [Record<string,never>] ?D:never
Defined in: packages/core/src/collections/api/types.ts:163
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.
Inherited from
Section titled “Inherited from”GenericQueryServerParams.depth
drafts?
Section titled “drafts?”
optionaldrafts?:boolean
Defined in: packages/core/src/collections/api/find/server.ts:158
Include draft rows for a versioned collection. Defaults to false.
The two-row draft model (design-review.md §1) means an unfiltered query on a
versioned collection returns the same logical document twice — once
vex_status: "published", once vex_status: "draft" — so find injects a
published-only constraint unless this is true. Ignored for a collection that
doesn’t declare versions.drafts.
Also switches the RBAC action this call resolves against, from "read" to
"readDrafts" (DRAFT_ACTIONS.readDrafts) — but only when the caller’s
role grants readDrafts at all. A caller without it silently falls back
to the published-only read (the same non-throwing fallback getGlobal
uses), so one set of query args serves every caller: the admin list view
and its server prefetch can both always send drafts: true for a
versioned collection without knowing who is asking.
limit?
Section titled “limit?”
optionallimit?:number
Defined in: packages/core/src/collections/api/find/server.ts:71
Maximum number of documents to return, applied as the terminal .take(n)
on the Convex query. Omit it, or pass 0, to return every matching
document (.collect()). Ignored when paginationOpts is set.
order?
Section titled “order?”
optionalorder?:"asc"|"desc"
Defined in: packages/core/src/collections/api/find/server.ts:77
Result ordering. Equivalent to .order("asc" | "desc") on the Convex
query. Defaults to "asc" (insertion order).
paginationOpts?
Section titled “paginationOpts?”
optionalpaginationOpts?:PaginationOptions
Defined in: packages/core/src/collections/api/find/server.ts:139
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.
populate?
Section titled “populate?”
optionalpopulate?: [D] extends [0] ?TPopulate:never
Defined in: packages/core/src/collections/api/types.ts:157
Recursive populate object, type-narrowed against RelationshipKeysOf<TCollectionSlug>.
Mutually exclusive with depth — becomes never when D ≠ 0.
Inherited from
Section titled “Inherited from”GenericQueryServerParams.populate
optionalsort?:CollectionTableSort<AccessDocFieldFor<TCollectionSlug>>
Defined in: packages/core/src/collections/api/find/server.ts:131
Portable sort — { field, order }. The server resolves field to an
index via resolveQueryIndex, which also pushes matching equalities
from where into that index’s range when one is available (Design
Decision 36) — callers never name an index directly (Design Decision
5). Mutually exclusive with withIndex — passing both throws a
VexError.
The resolved index competes for the query’s one withIndex slot
through the same pickConvexQueryIndex arbitration as withIndex (an
access-constraint index wins a free slot; a same-named index merges
ranges; a differently-named caller index displaces it and the access
rule falls back to .filter()) — sort carries no precedence of its
own over an access-contributed index.
Rejected with a VexAccessError when the caller cannot read
sort.field (Design Decision 26) — sort order alone would leak the
field’s values.
Example
Section titled “Example”find({ ctx, collection: "posts", sort: { field: "publishedAt", order: "desc" } })where?
Section titled “where?”
optionalwhere?:VexWhere<TCollectionSlug>
Defined in: packages/core/src/collections/api/find/server.ts:92
Predicate over the collection’s fields, applied after index narrowing.
Fields are referenced by name; combine with q.and / q.or / q.not.
Prefer withIndex for performance: on Convex, where scans every document
in the narrowed range.
Example
Section titled “Example”find({ ctx, collection: "posts", where: (q) => q.eq("published", true) })find({ ctx, collection: "posts", where: { field: "published", op: "eq", value: true } })withIndex?
Section titled “withIndex?”
optionalwithIndex?:VexWithIndex<TCollectionSlug>
Defined in: packages/core/src/collections/api/find/server.ts:105
Index to read through, with an optional range over its fields in
declaration order. Strongly preferred over where for performance.
Example
Section titled “Example”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" } })