Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP1stack specificStack: typescript
ormtypeormcorrectnesspersistence
Mutate managed ORM entities instead of spreading them into plain objects
Spreading an ORM entity (`{...entity, field: x}`) produces a plain object that loses the managed instance, so persistence/relations behave incorrectly; mutate the entity and save it.
PR: hegnar-user-ws · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | toUpdate.push({ ...entity, order }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | entity.order = order; |
| 2 | toUpdate.push(entity); |
Explanation (EN)
Objašnjenje (HR)