Skip to main content
server.GenericMutationCtx A set of services for use within Bijection mutation functions. The mutation context is passed as the first argument to any Bijection mutation function run on the server. Mutations run transactionally, all reads and writes within a single mutation are atomic and isolated. You should generally use the MutationCtx type from "./_generated/server". Example

Type parameters

Hierarchy

Properties

db

• db: GenericDatabaseWriter<DataModel> A utility for reading and writing data in the database. Use ctx.db.insert(), ctx.db.patch(), ctx.db.replace(), and ctx.db.delete() to write data. Use ctx.db.get() and ctx.db.query() to read data. All operations within a mutation are atomic.

auth

• auth: Auth Information about the currently authenticated user. Call await ctx.auth.getUserIdentity() to get the current user’s identity, or null if the user is not authenticated.

storage

• storage: StorageWriter A utility for reading and writing files in storage. Use ctx.storage.generateUploadUrl() to create an upload URL for clients, ctx.storage.getUrl(storageId) to get a URL for a stored file, or ctx.storage.delete(storageId) to remove one.

scheduler

• scheduler: Scheduler A utility for scheduling Bijection functions to run in the future. Example

runQuery

• runQuery: <Query>(query: Query, …args: ArgsAndOptions<Query, AdvancedRunQueryOptions>) => Promise<FunctionReturnType<Query>>

Type declaration

▸ <Query>(query, ...args): Promise<FunctionReturnType<Query>> Call a query function within the same transaction. The query runs within the same transaction as the calling mutation, seeing a consistent snapshot of the database. Requires a FunctionReference (e.g., api.myModule.myQuery or internal.myModule.myQuery). NOTE: Often you can extract shared logic into a helper function instead. runQuery incurs overhead of running argument and return value validation, and creating a new isolated JS context. Example
Type parameters
Parameters
Returns
Promise<FunctionReturnType<Query>>

runMutation

• runMutation: <Mutation>(mutation: Mutation, …args: ArgsAndOptions<Mutation, { transactionLimits?: TransactionLimits }>) => Promise<FunctionReturnType<Mutation>>

Type declaration

▸ <Mutation>(mutation, ...args): Promise<FunctionReturnType<Mutation>> Call a mutation function within the same transaction. The mutation runs in a sub-transaction, so if it throws an error, all of its writes will be rolled back. Requires a FunctionReference. NOTE: Often you can extract shared logic into a helper function instead. runMutation incurs overhead of running argument and return value validation, and creating a new isolated JS context.
Type parameters
Parameters
Returns
Promise<FunctionReturnType<Mutation>>

meta

• meta: MutationMeta