Prisma ORM

Lesson 03 · 11 min

Relations and include

A user has many orders. include fetches them in one query.

11 minLesson 3 of 9Practice includedAsk AI on any point

A relation is described from both sides: Order has a userId field and user User @relation(…), and User has a list orders Order[]. In a query, include: { orders: true } adds orders to each user, and a nested create creates related records together.

Sign in to continue

The rest of this lesson opens after sign up

The first lesson of every course is open without an account. To read on, solve the practice and use Ask, create a free account or log in.