Database Overview
By default, Blitz uses Prisma 2 which is a strongly typed database client.
Prisma 2 is not required for Blitz. You can use anything you want, such as Mongo, TypeORM, etc.
Read the Prisma documentation here
Add a Database Table
- Open
db/schema.prisma
and add your model(s) like as follows:
model Project {id Int @default(autoincrement()) @idname Stringtasks Task[]}model Task {id Int @default(autoincrement()) @idname Stringproject Project @relation(fields: [projectId], references: [id])projectId Int}
If you need,
reference the Prisma Schema documentation
- Then run
blitz db migrate
in your terminal to apply the changes - Now you can import
db
fromdb/index.ts
and create a model like this:db.project.create({data: {name: 'Hello'}})