Skip to content

Latest commit

 

History

History
77 lines (56 loc) · 1.21 KB

prisma.README.md

File metadata and controls

77 lines (56 loc) · 1.21 KB

express + nodejs

integrate with prisma + postgresql

0. Install Postgresql With Docker (Optional)

if you have a local postgresql or you want to use another database, just like sqlite

docker run --name postgres -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres

1. Install Prisma CLI

pnpm install @prisma/client

2. Init a Prisma Schema

npx prisma init

3. Migrate the database

npx prisma migrate dev --name init
npx prisma migrate resolve --applied init
npx prisma migrate dev --skip-generate --name init

4. Generate the prisma client

npx prisma generate
import {PrismaClient} from '@prisma/client'

const prisma = new PrismaClient({
  log:  ["error", "info", "warn", "query"]
})

export default prisma

6. Open the Prisma Studio

npx prisma studio

7. Using Prisma in Express

(async () => {
  return await prisma.tableName.findMany()
})()

8. Pull the database schema from database

npx prisma db pull

9. Push the database schema to database

npx prisma db push

deploy model with ollama

点我查看