# repositoriesFor() function · @imqueue/pg-prisma

Source: https://imqueue.org/api/pg-prisma/latest/pg-prisma.repositoriesfor/
Published: 2026-08-28
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/pg-prisma 2.0.0 — generated reference, not hand-written

Build the CRUD façade the RPC surface delegates to.

**Signature:**

```typescript
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](https://imqueue.org/api/pg-prisma/latest/pg-prisma.transactional/)\['transaction'\]; } | The client, as returned by the `postgres()` factory. |
| input | [RepositoryOptions](https://imqueue.org/api/pg-prisma/latest/pg-prisma.repositoryoptions/) |  |


**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


```typescript
const repository = repositoriesFor(db, { relations });

await repository.user.list<User>({ where: { active: { eq: true } } });
```

