Interface: GenericMutationCtx<DataModel>
server.GenericMutationCtx
A set of services for use within Convex mutation functions.
The mutation context is passed as the first argument to any Convex mutation function run on the server.
If you're using code generation, use the MutationCtx
type in
convex/_generated/server.d.ts
which is typed for your data model.
Type parameters
Name | Type |
---|---|
DataModel | extends GenericDataModel |
Properties
db
• db: GenericDatabaseWriter
<DataModel
>
A utility for reading and writing data in the database.
Defined in
auth
• auth: Auth
Information about the currently authenticated user.
Defined in
storage
• storage: StorageWriter
A utility for reading and writing files in storage.
Defined in
scheduler
• scheduler: Scheduler
A utility for scheduling Convex functions to run in the future.
Defined in
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
Name | Type |
---|---|
Query | extends FunctionReference <"query" , "public" | "internal" > |
Parameters
Name | Type |
---|---|
query | Query |
...args | OptionalRestArgs <Query > |
Returns
Promise
<FunctionReturnType
<Query
>>
Defined in
runMutation
• runMutation: <Mutation>(mutation
: Mutation
, ...args
: OptionalRestArgs
<Mutation
>) => Promise
<FunctionReturnType
<Mutation
>>
Type declaration
▸ <Mutation
>(mutation
, ...args
): Promise
<FunctionReturnType
<Mutation
>>
Call a mutation function within the same transaction.
NOTE: often you can call the mutation's function directly instead of using this.
runMutation
incurs overhead of running argument and return value validation,
and creating a new isolated JS context.
The mutation runs in a sub-transaction, so if the mutation throws an error, all of its writes will be rolled back. Additionally, a successful mutation's writes will be serializable with other writes in the transaction.
Type parameters
Name | Type |
---|---|
Mutation | extends FunctionReference <"mutation" , "public" | "internal" > |
Parameters
Name | Type |
---|---|
mutation | Mutation |
...args | OptionalRestArgs <Mutation > |
Returns
Promise
<FunctionReturnType
<Mutation
>>