Tessera docs

Launch Tessera

Launch

Database

Relations

Model one-to-many and many-to-many relations and load them in a single query.

One-to-many

A column with references() creates a one-to-many relation. The client exposes it in both directions.

TypeScript
const project = await db.projects.find(id, {  with: { tasks: { where: { done: false } } },})// project.tasks: Task[]

Many-to-many

Define a join table with two references. Tessera recognises the pattern and adds a through helper.

schema.ts
export const memberships = table("memberships", {  userId: uuid().references(() => users.id),  projectId: uuid().references(() => projects.id),}).primaryKey("userId", "projectId")

Loading strategy

Nested with clauses compile to a single SQL query using lateral joins, so loading relations never causes N+1 requests.

Select less

Combine with and select to fetch only the columns a view needs.

Was this helpful?

© 2026 Tessera, Inc.

Support

Status

Create a free website with Framer, the website builder loved by startups, designers and agencies.