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)Clientget()andsearch()calls. Usemgetormsearchfor independent reads. - AWS SDK v3 DynamoDB point reads:
send(new GetItemCommand(...))on aDynamoDBClient, orsend(new GetCommand(...))on aDynamoDBDocumentClient. Deduplicate keys before issuingBatchGetItemorBatchGetCommandin supported batch sizes (duplicate keys cause aValidationException), retry unprocessed keys, and map the returned items back to the original inputs. - Supabase reads built from
from(...).select(...)on aSupabaseClientthat are awaited or otherwise consumed. Use one bounded PostgREST.in(column, ids)read; because Supabase caps responses at 1,000 rows by default, paginate withrange()or otherwise confirm the response includes every matching row.
.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: