Prisma ORM

Lesson 01 · 10 min

Schema and models

One schema.prisma file describes the tables, and Prisma generates a typed client.

10 minLesson 1 of 9Practice includedAsk AI on any point

In schema.prisma you describe models, which are tables. Every field has a type and attributes: @id, @unique, @default. prisma generate creates a client where prisma.user.findMany() knows every field and suggests them in the editor.

The User model
AI

You can ask about this rule«The schema is the source of truth»

  • String? means the field may be NULL.
  • @default(cuid()) or @default(autoincrement()) generates the id.
  • DATABASE_URL in .env tells Prisma which database to connect to.
AI

You can ask about this point«Lesson summary»

Check

Lock it in before you move on

  1. 1. What does name String? mean?

  2. 2. What does prisma generate do?

  3. 3. Can you add a column by hand in the production database?

PracticeSolve the lesson tasksA few short tasks in the editor. Check your code right away and see where it goes wrong.Start practice