
- Provide a declarative way to define your database schema
- Generate type-safe database client
- Handle database migrations
- Offer powerful query capabilities with full TypeScript support
Default Configuration
By default, JTBDOS uses Neon as its database provider and Prisma as its ORM. However, you can easily switch to other providers if you’d prefer, for example:- You can use other ORMs like Drizzle, Kysely or any other type-safe ORM.
- You can use other database providers like PlanetScale, Prisma Postgres, Supabase, EdgeDB, or any other PostgreSQL/MySQL provider.
Usage
Database and ORM configuration is located in@repo/database
. You can import this package into any server-side component, like so:
Schema Definition
The database schema is defined inpackages/database/prisma/schema.prisma
. This schema file uses Prisma’s schema definition language to describe your database tables, relationships, and types.
Adding a new model
Let’s say we want to add a new model calledPost
, describing a blog post. The blog content will be in a JSON format, generated by a library like Tiptap. To do this, we would add the following to your schema:
packages/database/prisma/schema.prisma
Deploying changes
To deploy your schema changes, run the following command:Terminal
npx prisma format
to format the schema filenpx prisma generate
to generate the Prisma clientnpx prisma db push
to push the schema changes to the database