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

# orm-query-in-loop

> A TypeORM, Sequelize, Mongoose, Knex or Kysely operation runs once per loop iteration.

## What it flags

`orm-query-in-loop`, `drizzle-query-in-loop` and `orm-count-materialization` preserve the distinction between building a lazy statement and executing it. Counts with pagination, grouping, joins, hooks or scopes need particular care. TypeORM checks also identify entity reads used only for existence (`typeorm-existence-materialization`), unused wide columns in a direct DTO projection (`typeorm-wide-projection`), and a loop calling a local private helper that starts a transaction (`typeorm-transaction-in-loop`). Before changing a projection or an existence check, verify entity-load side effects. For per-row transactions, check rollback, ordering and error reporting before batching. The adapters recognize specific typed APIs. Custom methods with the same name, raw queries and wrappers often have different semantics.

In JavaScript and TypeScript, `orm-query-in-loop` also reports these datastore reads repeated once per loop item, recognized from their package types and method names:

* Elasticsearch (`@elastic/elasticsearch`) and OpenSearch (`@opensearch-project/opensearch`) `Client` `get()` and `search()` calls. Use `mget` or `msearch` for independent reads.
* AWS SDK v3 DynamoDB point reads: `send(new GetItemCommand(...))` on a `DynamoDBClient`, or `send(new GetCommand(...))` on a `DynamoDBDocumentClient`. Deduplicate keys before issuing `BatchGetItem` or `BatchGetCommand` in supported batch sizes (duplicate keys cause a `ValidationException`), retry unprocessed keys, and map the returned items back to the original inputs.
* Supabase reads built from `from(...).select(...)` on a `SupabaseClient` that are awaited or otherwise consumed. Use one bounded PostgREST `.in(column, ids)` read; because Supabase caps responses at 1,000 rows by default, paginate with `range()` or otherwise confirm the response includes every matching row.

A Supabase read whose `.in()` filter already receives the loop's whole collection is skipped. A loop that passes the previous result back into the next call as a cursor (pagination continuation) is skipped too. Wrappers and custom clients with the same method names are not recognized.

## Configuration

Set the rule to `"off"` in `loadwise.config.json` to drop its findings:

```json theme={null}
{
  "rules": { "orm-query-in-loop": "off" }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.