repositoriesFor() function
Build the CRUD façade the RPC surface delegates to.
Signature:
export declare function repositoriesFor<Repositories extends object = Record<string, Repository>>(db: {
orm: Record<string, Record<string, Collection>>;
transaction?: Transactional['transaction'];
}, input: RepositoryOptions): Repositories;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
db |
{ orm: Record<string, Record<string, Collection>>; transaction?: Transactional['transaction']; } |
The client, as returned by the |
|
input |
Returns:
Repositories
A repository per model, resolved on access.
Remarks
Under Prisma 7 this was generated: five methods for every model, each delegating to one of a handful of shared helpers — 800 lines of output that said the same thing fourteen times. Prisma Next addresses every model through the identical db.orm.<ns>.<Model> shape, so the façade is built at run time from the contract instead, and there is nothing to regenerate when a model is added.
Models are reached by their lower-camel name, as the generated repository exposed them: repository.user, repository.roleInheritance.
Pass the emitted Repositories interface as the type argument to make access total: without it every lookup is Repository | undefined, which is noise at each of a service's call sites.
Example
const repository = repositoriesFor(db, { relations });
await repository.user.list<User>({ where: { active: { eq: true } } });
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.