Task entity

Entities are one of the very central concepts in Wasp, and they mainly play the role of data models.

Since our TodoApp is all about tasks, we will define Task entity in Wasp:

// ...
entity Task {=psl
id Int @id @default(autoincrement())
description String
isDone Boolean @default(false)

Since Wasp uses Prisma as a database, definition of an entity comes down to defining a Prisma model, using PSL (Prisma Schema Language) inside the {=psl psl=} tags.

After this change and before running wasp start, we first need to run:

$ wasp db migrate-save "Added task entity"

This instructs Prisma to create a new database schema migration (you'll see a new directory migrations/ appeared in the root dir of our app) and apply it to the database.

To take a look at the database and the new Task schema, run:

$ wasp db studio
Todo App - Db studio showing Task schema

Click on the specific entity (we have only Task for now) and check out its fields! We don't have any data yet in our database, but we are about the change that.