Repository Factories
When to use
When building data access layers that need to work with different table schemas (test vs production) without duplicating code.
References
| Topic | File |
|---|---|
| Factory pattern overview | references/factory-pattern.md |
| Service dual-mode (index + test) | references/service-dual-mode.md |
| Generic admin system factory | references/admin-sys-factory.md |
Quick checklist
- Create one factory per domain, accepting tables as parameters
- Return an object with CRUD methods
- Use a type alias for the accepted table shape
- Cast with
as anyat the call site, not inside the factory - Create paired services:
index.ts(sys_*) andtest.ts(tst_*) - For simple CRUD tables, use the generic
createSysRepo()factory