[**Documentation**](../../../../README)

***

[Documentation](../../../../README) / [@zerotal/orm](../../README) / [index](../README) / preventNPlusOne

# Function: preventNPlusOne()

> **preventNPlusOne**(`options?`): `void`

Defined in: [packages/orm/src/db/NPlusOneDetector.ts:88](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/orm/src/db/NPlusOneDetector.ts#L88)

Configure N+1 query detection.

Call once at application boot to enable detection in any environment.
In `local` and `development` environments detection is already active with
default settings — call this to change the threshold or switch to 'throw'.

## Parameters

### options?

[`NPlusOneOptions`](../interfaces/NPlusOneOptions) = `{}`

## Returns

`void`

## Example

```ts
// bootstrap/app.ts (development)
import { DB } from '@zerotal/orm';
DB.preventNPlusOne({ threshold: 3, mode: 'throw' });
```
