Skip to main content
Prisma Documentation Docs

Search documentation

Type to search this documentation.

On this pageOverview

Select fields (Prisma ORM v7) (/docs/orm/v7/prisma-client/queries/select-fields)

For the complete Prisma documentation index, see llms.txt. A markdown version of any docs page is available by appending .md to its URL.

Learn how to return only the fields and relations you need with select and include in Prisma Client.

Location: ORM > v7 > Prisma Client > Queries > Select fields

By default, Prisma Client returns all scalar fields for a model and no relations. Use select and include to make the result smaller, clearer, and more intentional.

If you do not pass select, include, or omit, Prisma Client returns all scalar fields for the model and excludes relations from the result.

Use select when you only need a few scalar fields:

TypeScript
const user = await prisma.user.findFirst({
  select: {
    email: true,
    name: true,
  },
});

Return nested objects by selecting relation fields

Section titled “Return nested objects by selecting relation fields”

Use include when you want related records alongside the main result:

TypeScript
const user = await prisma.user.findFirst({
  include: {
    posts: true,
  },
});

You can combine both patterns to keep relation payloads focused:

TypeScript
const user = await prisma.user.findFirst({
  select: {
    email: true,
    posts: {
      select: {
        title: true,
        published: true,
      },
    },
  },
});

Omit fields instead of selecting everything manually

Section titled “Omit fields instead of selecting everything manually”

If you mostly want the default result but need to exclude a few fields, see Excluding fields.

  • Aggregation, grouping, and summarizing: Use Prisma Client to aggregate, group by, count, and select distinct.
  • CRUD: Learn how to perform create, read, update, and delete operations
  • Excluding fields: Learn how to exclude fields from Prisma Client results with the omit option.
  • Filtering and sorting: Learn how to filter Prisma Client queries with where and sort results with orderBy.
  • Full-text search: Learn how to search text fields with Prisma Client using your database's native full-text search support.
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu