Early Materialization (ARCH3056)
Key typescript.orm.early-materialization · Severity warning · Category orm
Pulling a query result into memory (list/array) first and then filtering/ordering/aggregating moves work that belongs in the database into the application. Push that work into the query.
Incorrect
Section titled “Incorrect”const all = await orderRepo.find();const active = all.filter(o => o.status === 'active'); // in-memory filterCorrect
Section titled “Correct”const active = await orderRepo.find({ where: { status: 'active' } });Push filtering/ordering/aggregation into the query with where/orderBy/aggregates.