Skip to main content

Interface: MutationMeta

For AI agents: see llms.txt for the complete documentation index. Markdown versions are available by adding .md to a page URL or requesting Accept: text/markdown.

server.MutationMeta

Extra context available in Convex mutation functions.

Hierarchy​

Methods​

getFunctionMetadata​

▸ getFunctionMetadata(): Promise<FunctionMetadata>

Metadata about the currently executing Convex function.

Returns​

Promise<FunctionMetadata>

Inherited from​

QueryMeta.getFunctionMetadata

Defined in​

server/meta.ts:144


getTransactionMetrics​

▸ getTransactionMetrics(): Promise<TransactionMetrics>

The remaining headroom for a transaction before hitting limits.

See https://docs.convex.dev/production/state/limits

Returns​

Promise<TransactionMetrics>

Inherited from​

QueryMeta.getTransactionMetrics

Defined in​

server/meta.ts:150


getDeploymentMetadata​

▸ getDeploymentMetadata(): Promise<DeploymentMetadata>

Metadata about the deployment this function is running on.

Returns​

Promise<DeploymentMetadata>

Inherited from​

QueryMeta.getDeploymentMetadata

Defined in​

server/meta.ts:154


getSnapshotTs​

▸ getSnapshotTs(): bigint

Returns the timestamp of the database snapshot this transaction reads from, in nanoseconds.

All commits at or before this timestamp are observable within the transaction, and no later commits are. The value is fixed for the lifetime of the transaction and shared with all nested runMutation and non-stale runQuery calls. If a nested query is called with useStaleSnapshot: true, then the nested query may in a future backend version choose an older snapshotTs.

It is on the same clock as db.vars.commitTs: documents observable in this transaction have commitTs values at or before this timestamp, and no new documents will be written with a commitTs at or below this, including from the current transaction. When reading documents with an index in commitTs order, you can use this as an upper bound to prevent conflicting with racing inserts.

Since the timestamp differs on every execution, calling this in a query limits caching of the query's result the same way Date.now() does.

Note: this should not be compared to _creationTime or Date.now(), as those are based on wall-clock time rather than the database clock, and aren't guaranteed to follow commit order.

Docs: https://docs.convex.dev/database/advanced/commit-timestamp

Returns​

bigint

Inherited from​

QueryMeta.getSnapshotTs

Defined in​

server/meta.ts:182


getRequestMetadata​

▸ getRequestMetadata(): Promise<RequestMetadata>

Metadata about the HTTP request that triggered the current function execution.

ip and userAgent are null when the function was not triggered by an HTTP request (e.g. scheduled jobs or cron jobs).

Functions called from within a function (i.e. using runMutation) will have the same request metadata as the parent function.

Returns​

Promise<RequestMetadata>

Defined in​

server/meta.ts:200