npx create-turbo@latest
- Initialize a
db
package that defines a simple prisma schema
cd packages
mkdir db
cd db
bun init
bun install prisma
bunx prisma init
model User {
id String @id @default(uuid())
username String
password String
}
docker run -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres
- Update the .env file with the right credentials
DATABASE_URL="postgresql://postgres:mysecretpassword@localhost:5432/postgres
- Migrate the DB, generate the client
bunx prisma migrate dev
bunx prisma generate
import { PrismaClient } from "@prisma/client";
export const prismaClient;
- Export db (update package.json)
"exports": {
"./client": "./index.ts"
}