Skip to main content

Interface: GenericQueryCtx<DataModel>

server.GenericQueryCtx

A set of services for use within Convex query functions.

The query context is passed as the first argument to any Convex query function run on the server.

This differs from the MutationCtx because all of the services are read-only.

Type parameters

NameType
DataModelextends GenericDataModel

Properties

db

db: GenericDatabaseReader<DataModel>

A utility for reading data in the database.

Defined in

server/registration.ts:130


auth

auth: Auth

Information about the currently authenticated user.

Defined in

server/registration.ts:135


storage

storage: StorageReader

A utility for reading files in storage.

Defined in

server/registration.ts:140


runQuery

runQuery: <Query>(query: Query, ...args: OptionalRestArgs<Query>) => Promise<FunctionReturnType<Query>>

Type declaration

▸ <Query>(query, ...args): Promise<FunctionReturnType<Query>>

Call a query function within the same transaction.

NOTE: often you can call the query's function directly instead of using this. runQuery incurs overhead of running argument and return value validation, and creating a new isolated JS context.

Type parameters
NameType
Queryextends FunctionReference<"query", "public" | "internal">
Parameters
NameType
queryQuery
...argsOptionalRestArgs<Query>
Returns

Promise<FunctionReturnType<Query>>

Defined in

server/registration.ts:149