Changelog - 2026-11-04
updateEach gives each row its own data in one transaction
New FeatureIn one line. repo.updateEach({ rows: [{ id, data }, ...] }) sets N rows to N different values in one call and one transaction, without a raw UPDATE ... FROM (VALUES ...) that skips the audit stamps and the row scope.
What changed
updateEach({ rows, options? })on the relationalPersistableRepository. Each row runs the wayupdateByIddoes: the write guard, the default filter, the row scope, hidden fields in the result and the audit stamps (modifiedAt,modifiedBy).- One transaction. Without
options.transactionthe repository opens one, commits at the end and rolls back on any error, so a refused payload or a failed statement writes nothing. Withoptions.transactionit joins yours and never commits it. - Order and misses. Rows apply in the order given and
datacomes back in that order. A row that matches nothing (missing, outside the scope, soft deleted) isnulland adds 0 tocount. - Edges. Empty
rowsreturn{ count: 0, data: [] }with no transaction.shouldReturn: falsereturnsdata: null. A nullidthrows before that row is written.
Who is affected
- Callers that update many rows with different values. Use
updateEachinstead of NupdateByIdcalls. - Everyone else. No action needed. The method is on the relational repository only, so the search and remote repositories are unchanged.
Details
typescript
const { count, data } = await productRepository.updateEach({
rows: [
{ id: 'p-1', data: { price: 120 } },
{ id: 'p-2', data: { price: 95 } },
],
});It costs N statements in one transaction, not one statement. See Repositories.