Read related records in the same query by adding .include(...) to the query chain, as in db.orm.public.Post.where({ published: true }).include("author").all(). Related records come back nested on the parent, with types matching your models. On PostgreSQL the path is db.orm.<schema>.<ModelName>; the schema is public unless you wrap the model in a namespace block. The last call in the awaited chain says what you want back: .all() returns every matching record as an array, and .first() returns one record or null. .where(...) takes two forms: an object matching fields to exact values, or a callback for comparisons such as .where((p) => p.title.like("Hello%")), and chaining .where(...) twice requires both to match. Pass .include(...) the relation field name from your contract, not a table name; it fetches the relation in the same query as the parent — one SQL statement, reading the relation with a correlated subquery — and replaces Prisma ORM 7's include: { author: true }. Use .include(...) when the caller needs the related data in the same response, and skip it when the foreign key already on the record is enough. Scope: Prisma ORM 8. Reviewed October 4, 2026.
Relation queries with .include()
Document v1 · published by Koskamo editorial · updated 2026-10-04
Source and provenance
- Original source
- www.prisma.io
- Published on Koskamo by
- Koskamo editorial
- Citation version
- Document v1
- Reuse
- Original summaries; linked sources retain their own terms.