> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Interface: BijectionMutationCtx<DataModel>

> Reference for the BijectionMutationCtx interface in bijection/server.

[server](/api/modules/server).BijectionMutationCtx

## Type parameters

| Name | Type |
| :- | :- |
| `DataModel` | extends [`GenericDataModel`](/api/modules/server#genericdatamodel) |

## Hierarchy

* [`GenericMutationCtx`](/api/interfaces/server.GenericMutationCtx)\<`DataModel`>

  ↳ **`BijectionMutationCtx`**

## Properties

### sources

• **sources**: [`Sources`](/api/interfaces/server.Sources)

***

### externalCalls

• **externalCalls**: [`ExternalCalls`](/api/interfaces/server.ExternalCalls)

***

### approvals

• **approvals**: [`Approvals`](/api/interfaces/server.Approvals)

***

### storage

• **storage**: [`BijectionStorageWriter`](/api/interfaces/server.BijectionStorageWriter)

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.

#### Overrides

[GenericMutationCtx](/api/interfaces/server.GenericMutationCtx).[storage](/api/interfaces/server.GenericMutationCtx#storage)

***

### occurrence

• **occurrence**: [`OccurrenceCustody`](/api/interfaces/server.OccurrenceCustody)

***

### db

• **db**: [`GenericDatabaseWriter`](/api/interfaces/server.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.

#### Inherited from

[GenericMutationCtx](/api/interfaces/server.GenericMutationCtx).[db](/api/interfaces/server.GenericMutationCtx#db)

***

### auth

• **auth**: [`Auth`](/api/interfaces/server.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.

#### Inherited from

[GenericMutationCtx](/api/interfaces/server.GenericMutationCtx).[auth](/api/interfaces/server.GenericMutationCtx#auth)

***

### scheduler

• **scheduler**: [`Scheduler`](/api/interfaces/server.Scheduler)

A utility for scheduling Bijection functions to run in the future.

**`Example`**

```typescript theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
// Schedule an action to run immediately after this mutation commits:
await ctx.scheduler.runAfter(0, internal.emails.sendWelcome, { userId });

// Schedule a cleanup to run in 24 hours:
await ctx.scheduler.runAfter(24 * 60 * 60 * 1000, internal.tasks.cleanup, {});
```

#### Inherited from

[GenericMutationCtx](/api/interfaces/server.GenericMutationCtx).[scheduler](/api/interfaces/server.GenericMutationCtx#scheduler)

***

### runQuery

• **runQuery**: \<Query>(`query`: `Query`, ...`args`: [`ArgsAndOptions`](/api/modules/server#argsandoptions)\<`Query`, [`AdvancedRunQueryOptions`](/api/interfaces/server.AdvancedRunQueryOptions)>) => `Promise`\<[`FunctionReturnType`](/api/modules/server#functionreturntype)\<`Query`>>

#### Type declaration

▸ \<`Query`>(`query`, `...args`): `Promise`\<[`FunctionReturnType`](/api/modules/server#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](/api/modules/server#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`**

```typescript theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
const user = await ctx.runQuery(internal.users.getUser, { userId });
```

##### Type parameters

| Name | Type |
| :- | :- |
| `Query` | extends [`FunctionReference`](/api/modules/server#functionreference)\<`"query"`, `"public"` \| `"internal"`> \| [`FunctionReference_future`](/api/modules/server#functionreference_future)\<`"query"`, `"public"` \| `"internal"`> |

##### Parameters

| Name | Type |
| :- | :- |
| `query` | `Query` |
| `...args` | [`ArgsAndOptions`](/api/modules/server#argsandoptions)\<`Query`, [`AdvancedRunQueryOptions`](/api/interfaces/server.AdvancedRunQueryOptions)> |

##### Returns

`Promise`\<[`FunctionReturnType`](/api/modules/server#functionreturntype)\<`Query`>>

#### Inherited from

[GenericMutationCtx](/api/interfaces/server.GenericMutationCtx).[runQuery](/api/interfaces/server.GenericMutationCtx#runquery)

***

### runMutation

• **runMutation**: \<Mutation>(`mutation`: `Mutation`, ...`args`: [`ArgsAndOptions`](/api/modules/server#argsandoptions)\<`Mutation`, \{ `transactionLimits?`: [`TransactionLimits`](/api/interfaces/server.TransactionLimits)  }>) => `Promise`\<[`FunctionReturnType`](/api/modules/server#functionreturntype)\<`Mutation`>>

#### Type declaration

▸ \<`Mutation`>(`mutation`, `...args`): `Promise`\<[`FunctionReturnType`](/api/modules/server#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](/api/modules/server#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

| Name | Type |
| :- | :- |
| `Mutation` | extends [`FunctionReference`](/api/modules/server#functionreference)\<`"mutation"`, `"public"` \| `"internal"`> \| [`FunctionReference_future`](/api/modules/server#functionreference_future)\<`"mutation"`, `"public"` \| `"internal"`> |

##### Parameters

| Name | Type |
| :- | :- |
| `mutation` | `Mutation` |
| `...args` | [`ArgsAndOptions`](/api/modules/server#argsandoptions)\<`Mutation`, \{ `transactionLimits?`: [`TransactionLimits`](/api/interfaces/server.TransactionLimits)  }> |

##### Returns

`Promise`\<[`FunctionReturnType`](/api/modules/server#functionreturntype)\<`Mutation`>>

#### Inherited from

[GenericMutationCtx](/api/interfaces/server.GenericMutationCtx).[runMutation](/api/interfaces/server.GenericMutationCtx#runmutation)

***

### meta

• **meta**: [`MutationMeta`](/api/interfaces/server.MutationMeta)

#### Inherited from

[GenericMutationCtx](/api/interfaces/server.GenericMutationCtx).[meta](/api/interfaces/server.GenericMutationCtx#meta)
