diff --git a/apps/core/express-based/README.md b/apps/core/express-based/README.md new file mode 100644 index 00000000..824d4dec --- /dev/null +++ b/apps/core/express-based/README.md @@ -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() +})() +``` \ No newline at end of file diff --git a/apps/core/express-based/src/utils/prisma.ts b/apps/core/express-based/src/utils/prisma.ts index 0c88892e..2b92932e 100644 --- a/apps/core/express-based/src/utils/prisma.ts +++ b/apps/core/express-based/src/utils/prisma.ts @@ -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 \ No newline at end of file