---
url: >-
  https://scruple.dev/rules/relational-databases/require-transaction-scoped-client.md
description: Require transaction-scoped database clients.
---

# relational-databases/require-transaction-scoped-client

Require transaction-scoped database clients.

## What it checks

Work inside callback transactions and manual BEGIN flows should use the transaction-scoped client rather than a global client or pool.

## Rule metadata

* Package: `@scruple/relational-databases`
* Category: Database correctness
* Tags: transactions, clients, atomicity
* Default threshold: `plugin default`
* Minimum confidence: `plugin default`

## Examples

### Reported

```ts
db.transaction(async tx => { await db.account.update(data); });
```

### Accepted

```ts
db.transaction(async tx => { await tx.account.update(data); });
```
