confect/_generated/services.ts and are available when implementing your Confect functions and HTTP endpoint handlers.
Database
DatabaseReader
Read documents from the database.
DatabaseWriter
Insert, edit, and delete documents from the database.
Function invocation
QueryRunner
Run Confect queries with runQuery(ref, args, options?):
transactionLimits option is available inside queries and mutations.
The useStaleSnapshot option is available only inside mutations, even when
you pass false. Actions and HTTP handlers can call runQuery without these
options. See Transaction controls.
MutationRunner
Run Confect mutations with runMutation(ref, args, options?). Obtain the
method with const { runMutation } = yield* MutationRunner.
The transactionLimits option is available only inside mutations. Actions
and HTTP handlers can call runMutation without this option.
ActionRunner
Run Confect actions with runAction(ref, args). Obtain the method with
const { runAction } = yield* ActionRunner. This method has no options
parameter.
For all three runners, args is optional when the referenced function takes
no arguments. Pass {} as the second argument when supplying options to a
no-argument query or mutation.
Transaction controls
Pass transaction options to a runner method to control a nested call, not the entire enclosing handler:transactionLimits accepts Convex’s TransactionLimits fields, including
documentsRead, bytesRead, and databaseQueries. Each field sets a maximum
for the nested call. Convex caps these values at its platform transaction
limits. Use
TransactionMetadata.getMetrics()
to inspect usage and remaining limits.
In actions and HTTP handlers, omit options or pass
undefined rather than
an empty options object.
useStaleSnapshot: true reads from a recent database snapshot that might
not be up to date when the mutation commits. Passing
useStaleSnapshot: false still requires a mutation context.
Storage
Storage
Use one service for file storage. The available operations depend on the function’s context:
See Storage for examples and return types.
StorageWriter and StorageActionWriter may appear in operation
requirements. Confect supplies them automatically; new code only needs to
import Storage. The existing storage service exports and generated aliases
remain available for compatibility.