Selecting fields

By default, a query returns all readable scalar fields. Selecting only the fields that you require rather than relying on the default selection set can reduce the size of the response and improve query speed.

Teo's frontend API design is slightly different from Prisma. To including relations, see Relation queries.

The selection can be nested inside related relations, too. The following query returns only artist name and song name.

const { data: artists } = await teo.artist.findMany({
  select: {
    name: true
  },
  include: {
    songs: {
      select: {
        name: true
      }
    },
  }
})
Hide HTTP response
[
  {
    "name": "Angela Peterson",
    "songs": [
      {
        "name": "Forever in Safe"
      },
      {
        "name": "Fairy Tale"
      }
    ]
  },
  {
    "name": "Tony Justin",
    "songs": []
  }
]