Slide 1

Slide 1 text

0 Object‒relational mapping and query builder battle 1: Intro to Prisma 2024-06-21 第95回NearMe技術勉強会 Cyan

Slide 2

Slide 2 text

1 What is ORM(Object‒relational mapping)? The way we want to interact with data The way data is stored in sql database

Slide 3

Slide 3 text

2 Prisma Syntax https://www.prisma.io/docs/orm/ove rview/introduction/what-is-prisma

Slide 4

Slide 4 text

3 Prisma Workflows 1. Schema Center 2. Database Center https://www.prisma.io/docs/orm/ove rview/introduction/what-is-prisma

Slide 5

Slide 5 text

4 Prisma Architecture https://www.prisma.io/docs/orm/mor e/under-the-hood/engines

Slide 6

Slide 6 text

5 Let’s see an example

Slide 7

Slide 7 text

6 Prisma Schema # clone the repo git clone [email protected]:yukimotochern/nearme-study -session.git # install npm install

Slide 8

Slide 8 text

7 Start Database and Migrate cd projects/orm-battle || exit // start database docker compose up -d // migrate schema npx nx migrate prisma // build server npx nx build prisma // run server npx nx serve prisma

Slide 9

Slide 9 text

8 Prisma Queries `projects/orm0620/prisma/src/app/routes/root.ts`

Slide 10

Slide 10 text

9 Prisma Queries (conti.)

Slide 11

Slide 11 text

10 Prisma Pros and Cons - Pros - Totally Type Safe - Clear and concise database schema with great IDE support - Documentation is EXTRAORDINARY. - Database agnostic schema definition for basic usage - `Select` only required information => performance++ - No more `select * from` - Cons - Another Rust client that might have overhead - Additional client generating process - Hard to extend => prisma-zod generator was buggy when I used it.

Slide 12

Slide 12 text

11 Thank you