alepha@docs:~/docs/reference/primitives$
cat $repositories.md | pretty1 min read
#$repositories
#Import
typescript
1import { $repositories } from "alepha/orm";
#Overview
One relation-aware repository per entity, in a single binding.
$repository(relations, "campaigns") is the explicit form for one entity;
this is the ergonomic one for a service that touches several. Plural name,
plural result — $repository always hands back exactly one repository.
It also removes a footgun: binding every entity at once means each one is registered with the database provider before any schema is built, so a foreign key can never point at a table that has not been registered yet. With per-entity bindings that ordering is the caller's problem.
#Examples
ts
1class CampaignService { 2 db = $repositories(relations); 3 4 async members(id: number) { 5 return await this.db.characters.findMany({ 6 where: { campaignId: { eq: id } }, 7 include: { user: true }, 8 }); 9 }10}