Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Define storage mappings for each document kind
When initialization creates multiple stores for different document shapes, assign each store its own mapping instead of copying an unrelated mapping into every store.
Bad example
| 1 | for (const name of ['records', 'checkpoint']) await createIndex(name, recordMapping); |
Explanation (EN)
When initialization creates multiple stores for different document shapes, assign each store its own mapping instead of copying an unrelated mapping into every store.
Objašnjenje (HR)
Primjer ne provodi opisanu zastitu.
Good example
| 1 | for (const [name, mapping] of Object.entries({ records: recordMapping, checkpoint: checkpointMapping })) { |
| 2 | await createIndex(name, mapping); |
| 3 | } |
Explanation (EN)
Apply when initializing data and control-state stores. Reuse the initialization flow while keeping each document schema explicit. Shared field definitions can be reused where their semantics match. Avoid validating an already validated shape again only to remove a field, use object rest instead.
Objašnjenje (HR)
Provjeri uvjete prije operacije i sacuvaj jasno definirano ponasanje.
Notes (EN)
Apply when initializing data and control-state stores. Reuse the initialization flow while keeping each document schema explicit. Shared field definitions can be reused where their semantics match. Avoid validating an already validated shape again only to remove a field, use object rest instead.
Bilješke (HR)
Primijeni kod spremanja podataka i skupnih operacija kada vrijede opisani uvjeti.
Exceptions / Tradeoffs (EN)
Multiple stores that intentionally contain the same document shape may share one mapping.
Iznimke / Tradeoffi (HR)
Iznimke ovise o ugovoru sustava navedenom u engleskom opisu.