Domain Repos
Domain repos are shared data access layers within a domain. For shared concepts like constraint handling and repo structure, see the Repos Overview.
When to Use
- Data operations shared across multiple endpoints in a domain
- Queries reused in multiple use-cases
- Data access needed by both use-cases and domain services
Always Transactional
Domain repos extend TransactionalRepo and use this.trx. They run within the transaction context of the calling use-case.
Creating
- Run the CLI:
bash
pnpm devuxSelect "Domain Repos" → "Create"
Choose the target domain
Enter repo details:
- Repo name (kebab-case, e.g.,
find-customer-by-id) - Operation type (read, write, delete)
- Repo name (kebab-case, e.g.,
Adding as Dependency
To use a domain repo in a use-case or domain service:
Run "Endpoints" → "Manage dependencies" (for use-cases)
Or "Domain Services" → "Manage dependencies" (for domain services)
Select "Domain repos" → "Add"
Choose the domain repo
Location
domains/{domain}/repos/{repo}/
├── {repo}.repo.ts
├── {repo}.repo.zod.schemas.ts
└── tests/
└── {repo}.repo.test.ts