Skip to main content
zerotal

Documentation


Documentation / @zerotal/orm / index / preventNPlusOne

Function: preventNPlusOne()

preventNPlusOne(options?): void

Defined in: packages/orm/src/db/NPlusOneDetector.ts:88

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 = {}

Returns

void

Example

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