Skip to content

Commit

Permalink
feat: readme prisma
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-season-bankup committed Aug 27, 2024
1 parent eff3f0b commit da01254
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
56 changes: 56 additions & 0 deletions apps/core/express-based/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# express + nodejs

## integrate with prisma + postgresql

### 0. Install Postgresql With Docker

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

### 1. Install Prisma CLI

```sh
pnpm install @prisma/client
```
### 2. Init a Prisma Schema

```sh
npx prisma init
```

### 3. Migrate the database

```sh
npx prisma migrate dev --name initname
```

### 4. Generate the prisma client

```sh
npx prisma generate
```

```js
import {PrismaClient} from '@prisma/client'

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

export default prisma
```

### 6. Open the Prisma Studio

```sh
npx prisma studio
```

### 7. Using Prisma in Express

```sh
(async () => {
return await prisma.tableName.findMany()
})()
```
2 changes: 1 addition & 1 deletion apps/core/express-based/src/utils/prisma.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {PrismaClient} from '@prisma/client'

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

export default prisma

0 comments on commit da01254

Please sign in to comment.