SlideShare a Scribd company logo
1 of 47
Download to read offline
Luca Del Puppo - Senior Software Engineer
Prisma the ORM that node was waiting for
Luca Del Puppo
Senior Software Engineer
Javascript Enthusiastic
Typescript Lover
“Youtuber”
“Writer”
Love sport: running, hiking
Love animals
Agenda
. What is it?
. CLI
. Data Modeling
. Generation
. Client
. Migration
. Deploy
. Conclusion
What is it?
Prisma is an open source next-generation ORM.
(Node eco-system)
Prisma Client
Auto-generated and type-safe query builder for Node.js & TypeScript
Prisma Migrate
Migration system
Prisma Studio
GUI to view and edit data in your database
Control
Productivity
Orm
Plain SQL
SQL Builder
Prisma
Healty Constraint
Providers
PostgreSQL
MySQL
SQLite
Microsoft SQL Server
MongoDB
CockroachDB
Hey Bro!
Could you talk about
interesting stu ?
Image by on
catalyststu Freepik
CLI
Install CLI
Create Project
Prisma File
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
1
2
3
4
5
6
7
8
CLI commands
init
generate
migrate
Data Modelling
Schema
One le (schema.prisma)
Data sources
Generators
Data model de nition
Syntax - PSL (Prisma Schema Language)
N.B. Multiple Files is not supported yet
Generator & DataSource
generator client {
provider = "prisma-client-js"
}
1
2
3
4
datasource db {
5
provider = "postgresql"
6
url = env("DATABASE_URL")
7
}
8
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
1
provider = "prisma-client-js"
2
}
3
4
5
6
7
8
Models
model Ingredient {
1
id Int @id @default(autoincrement())
2
name String
3
createdAt DateTime @default(now())
4
updatedAt DateTime @updatedAt
5
pizzaIngredients PizzaIngredient[]
6
7
@@map("INGREDIENTS")
8
}
9
id Int @id @default(autoincrement())
model Ingredient {
1
2
name String
3
createdAt DateTime @default(now())
4
updatedAt DateTime @updatedAt
5
pizzaIngredients PizzaIngredient[]
6
7
@@map("INGREDIENTS")
8
}
9
createdAt DateTime @default(now())
model Ingredient {
1
id Int @id @default(autoincrement())
2
name String
3
4
updatedAt DateTime @updatedAt
5
pizzaIngredients PizzaIngredient[]
6
7
@@map("INGREDIENTS")
8
}
9
updatedAt DateTime @updatedAt
model Ingredient {
1
id Int @id @default(autoincrement())
2
name String
3
createdAt DateTime @default(now())
4
5
pizzaIngredients PizzaIngredient[]
6
7
@@map("INGREDIENTS")
8
}
9
@@map("INGREDIENTS")
model Ingredient {
1
id Int @id @default(autoincrement())
2
name String
3
createdAt DateTime @default(now())
4
updatedAt DateTime @updatedAt
5
pizzaIngredients PizzaIngredient[]
6
7
8
}
9
model Ingredient {
id Int @id @default(autoincrement())
name String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
pizzaIngredients PizzaIngredient[]
@@map("INGREDIENTS")
}
1
2
3
4
5
6
7
8
9
Relations
ingredientId Int
ingredient Ingredient @relation(fields: [ingredientId], references: [id])
model PizzaIngredient {
1
2
pizzaId Int
3
4
pizza Pizza @relation(fields: [pizzaId], references: [id])
5
6
@@id([pizzaId, ingredientId])
7
8
@@map("PIZZA_INGREDIENTS")
9
}
10
pizzaId Int
pizza Pizza @relation(fields: [pizzaId], references: [id])
model PizzaIngredient {
1
ingredientId Int
2
3
ingredient Ingredient @relation(fields: [ingredientId], references: [id])
4
5
6
@@id([pizzaId, ingredientId])
7
8
@@map("PIZZA_INGREDIENTS")
9
}
10
@@id([pizzaId, ingredientId])
model PizzaIngredient {
1
ingredientId Int
2
pizzaId Int
3
ingredient Ingredient @relation(fields: [ingredientId], references: [id])
4
pizza Pizza @relation(fields: [pizzaId], references: [id])
5
6
7
8
@@map("PIZZA_INGREDIENTS")
9
}
10
model PizzaIngredient {
ingredientId Int
pizzaId Int
ingredient Ingredient @relation(fields: [ingredientId], references: [id])
pizza Pizza @relation(fields: [pizzaId], references: [id])
@@id([pizzaId, ingredientId])
@@map("PIZZA_INGREDIENTS")
}
1
2
3
4
5
6
7
8
9
10
Generation
Generation
What does it generate?
Models
Convert Models to Typescript Types
Client
Query Models (type safe)
Constraint to build where clause
Constraint to build select
Constraint to build insert/update/delete with relation
Generated Type
export type Ingredient = {
id: number
name: string
createdAt: Date
updatedAt: Date
}
1
2
3
4
5
6
Client
Installation
What does it generate?
const prisma = new PrismaClient();
1
await prisma.$connect();
2
3
const pizza = await prisma.pizza.findUnique({
4
where: {
5
id: id,
6
},
7
include: {
8
pizzaIngredients: {
9
include: {
10
ingredient: true,
11
},
12
},
13
},
14
});
15
await prisma.$connect();
const prisma = new PrismaClient();
1
2
3
const pizza = await prisma.pizza.findUnique({
4
where: {
5
id: id,
6
},
7
include: {
8
pizzaIngredients: {
9
include: {
10
ingredient: true,
11
},
12
},
13
},
14
});
15
const pizza = await prisma.pizza.findUnique({
where: {
id: id,
},
include: {
pizzaIngredients: {
include: {
ingredient: true,
},
},
},
});
const prisma = new PrismaClient();
1
await prisma.$connect();
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const prisma = new PrismaClient();
await prisma.$connect();
const pizza = await prisma.pizza.findUnique({
where: {
id: id,
},
include: {
pizzaIngredients: {
include: {
ingredient: true,
},
},
},
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Image by on
catalyststu Freepik
Crud
SQLPrisma Single Multiple
Insert create createMany
Update update updateMany
Delete delete deleteMany
Select ndUnique/
ndFirst
ndMany
Insert/
Update
upsert
Image by on
catalyststu Freepik
Aggregation
Aggregate
Count
GroupBy
One for each model
Migration
Image by on
catalyststu Freepik
Prisma Schema Prisma CLI Database
1. update
2. prisma migrate dev
3. read schema
4. database schema
5. generate migration
6. update database
Migration ow
Image by on
catalyststu Freepik
Prisma Schema
Prisma CLI Database
2. prisma db pull
Introspection ow
1. Change database schema (SQL)
3. read schema
4. database schema
5. Update
Limitations
MongoDb is not supported (use prisma db push)
Switch DB Provider is not supported
Seeding
Prisma exposes us a command for seeding the db
It runs on
prisma migrate dev
prisma migrate reset
manually
It can be written in typescript, go, sql…
--skip-seed allows skipping
Deploy
N.B. Use a CI/CD ow for your deployment
Demo
Image by on
catalyststu Freepik
Conclusion
Cons
Newby
Don’t manage multiple provider concurrency
Splitting schema not implemented out-of-the-box (prisma-
aurora)
Pros
Wonderful developer experience
Type safe queries
Migrations
Custom queries
Active Community
Awesome documentation
Core team active in Github and Slack
Slides
Image by on
catalyststu Freepik
Prisma Series
Image by on
catalyststu Freepik
We are hiring
Image by on
catalyststu Freepik
Luca Del Puppo
@puppo92
Luca Del Puppo
Puppo_92
@puppo

More Related Content

What's hot

From devoops to devops 13 years of (not) learning
From devoops to devops 13 years of (not) learningFrom devoops to devops 13 years of (not) learning
From devoops to devops 13 years of (not) learningKris Buytaert
 
Cloud run - Serverless Containers Done Right
Cloud run - Serverless Containers Done RightCloud run - Serverless Containers Done Right
Cloud run - Serverless Containers Done Rightmfazal
 
Nginx Testing in NAVER
Nginx Testing in NAVERNginx Testing in NAVER
Nginx Testing in NAVER형근 송
 
PostgreSQL: Joining 1 million tables
PostgreSQL: Joining 1 million tablesPostgreSQL: Joining 1 million tables
PostgreSQL: Joining 1 million tablesHans-Jürgen Schönig
 
Mysql data replication
Mysql data replicationMysql data replication
Mysql data replicationTuấn Ngô
 
Azure Active Directory - An Introduction
Azure Active Directory  - An IntroductionAzure Active Directory  - An Introduction
Azure Active Directory - An IntroductionVenkatesh Narayanan
 
우아한 모노리스
우아한 모노리스우아한 모노리스
우아한 모노리스Arawn Park
 
HAProxy as Egress Controller
HAProxy as Egress ControllerHAProxy as Egress Controller
HAProxy as Egress ControllerJulien Pivotto
 
SOLID Principles and The Clean Architecture
SOLID Principles and The Clean ArchitectureSOLID Principles and The Clean Architecture
SOLID Principles and The Clean ArchitectureMohamed Galal
 
Using Recursive Common Table Expressions with Ecto
Using Recursive Common Table Expressions with EctoUsing Recursive Common Table Expressions with Ecto
Using Recursive Common Table Expressions with EctoMaarten van Vliet
 
Automating Your Way to Greatness by Combining OutSystems CI/CD With the Power...
Automating Your Way to Greatness by Combining OutSystems CI/CD With the Power...Automating Your Way to Greatness by Combining OutSystems CI/CD With the Power...
Automating Your Way to Greatness by Combining OutSystems CI/CD With the Power...OutSystems
 
ProxySQL for MySQL
ProxySQL for MySQLProxySQL for MySQL
ProxySQL for MySQLMydbops
 
Clean architecture
Clean architectureClean architecture
Clean architecture.NET Crowd
 

What's hot (20)

From devoops to devops 13 years of (not) learning
From devoops to devops 13 years of (not) learningFrom devoops to devops 13 years of (not) learning
From devoops to devops 13 years of (not) learning
 
Cloud run - Serverless Containers Done Right
Cloud run - Serverless Containers Done RightCloud run - Serverless Containers Done Right
Cloud run - Serverless Containers Done Right
 
Nginx Testing in NAVER
Nginx Testing in NAVERNginx Testing in NAVER
Nginx Testing in NAVER
 
PostgreSQL: Joining 1 million tables
PostgreSQL: Joining 1 million tablesPostgreSQL: Joining 1 million tables
PostgreSQL: Joining 1 million tables
 
NGINX Plus on AWS
NGINX Plus on AWSNGINX Plus on AWS
NGINX Plus on AWS
 
Mysql data replication
Mysql data replicationMysql data replication
Mysql data replication
 
MVVM
MVVMMVVM
MVVM
 
Azure Active Directory - An Introduction
Azure Active Directory  - An IntroductionAzure Active Directory  - An Introduction
Azure Active Directory - An Introduction
 
NestJS
NestJSNestJS
NestJS
 
우아한 모노리스
우아한 모노리스우아한 모노리스
우아한 모노리스
 
HAProxy as Egress Controller
HAProxy as Egress ControllerHAProxy as Egress Controller
HAProxy as Egress Controller
 
SOLID Principles and The Clean Architecture
SOLID Principles and The Clean ArchitectureSOLID Principles and The Clean Architecture
SOLID Principles and The Clean Architecture
 
Splunk 교육자료 v1.2
Splunk 교육자료 v1.2Splunk 교육자료 v1.2
Splunk 교육자료 v1.2
 
Using Recursive Common Table Expressions with Ecto
Using Recursive Common Table Expressions with EctoUsing Recursive Common Table Expressions with Ecto
Using Recursive Common Table Expressions with Ecto
 
AKS
AKSAKS
AKS
 
Mvc, mvp, mvvm...
Mvc, mvp, mvvm...Mvc, mvp, mvvm...
Mvc, mvp, mvvm...
 
MySQL Tuning
MySQL TuningMySQL Tuning
MySQL Tuning
 
Automating Your Way to Greatness by Combining OutSystems CI/CD With the Power...
Automating Your Way to Greatness by Combining OutSystems CI/CD With the Power...Automating Your Way to Greatness by Combining OutSystems CI/CD With the Power...
Automating Your Way to Greatness by Combining OutSystems CI/CD With the Power...
 
ProxySQL for MySQL
ProxySQL for MySQLProxySQL for MySQL
ProxySQL for MySQL
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 

Similar to Prisma the ORM that node was waiting for

SPKonferenz 2017 - Introducing SDKs for Microsoft Graph
SPKonferenz 2017 - Introducing SDKs for Microsoft GraphSPKonferenz 2017 - Introducing SDKs for Microsoft Graph
SPKonferenz 2017 - Introducing SDKs for Microsoft GraphDragan Panjkov
 
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...DataLeader.io
 
SharePoint Saturday Belgium 2018 - APIs, APIs everywhere!
SharePoint Saturday Belgium 2018 - APIs, APIs everywhere!SharePoint Saturday Belgium 2018 - APIs, APIs everywhere!
SharePoint Saturday Belgium 2018 - APIs, APIs everywhere!Sébastien Levert
 
APIs, APIs Everywhere!
APIs, APIs Everywhere!APIs, APIs Everywhere!
APIs, APIs Everywhere!BIWUG
 
SharePoint Saturday Chicago - Everything your need to know about the Microsof...
SharePoint Saturday Chicago - Everything your need to know about the Microsof...SharePoint Saturday Chicago - Everything your need to know about the Microsof...
SharePoint Saturday Chicago - Everything your need to know about the Microsof...Sébastien Levert
 
Making Things Work Together
Making Things Work TogetherMaking Things Work Together
Making Things Work TogetherSubbu Allamaraju
 
SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!Sébastien Levert
 
Forge - DevCon 2016: Introduction to Forge 3D Print API Through Sample Applic...
Forge - DevCon 2016: Introduction to Forge 3D Print API Through Sample Applic...Forge - DevCon 2016: Introduction to Forge 3D Print API Through Sample Applic...
Forge - DevCon 2016: Introduction to Forge 3D Print API Through Sample Applic...Autodesk
 
SharePoint Conference 2018 - Build an intelligent application by connecting i...
SharePoint Conference 2018 - Build an intelligent application by connecting i...SharePoint Conference 2018 - Build an intelligent application by connecting i...
SharePoint Conference 2018 - Build an intelligent application by connecting i...Sébastien Levert
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3masahiroookubo
 
MongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB
 
Silverlight 5 whats new overview
Silverlight 5 whats new overviewSilverlight 5 whats new overview
Silverlight 5 whats new overviewmdc11
 
SharePoint 2010 Client Object Model
SharePoint 2010 Client Object ModelSharePoint 2010 Client Object Model
SharePoint 2010 Client Object ModelG. Scott Singleton
 
Frontend APIs powering fast paced product iterations
Frontend APIs powering fast paced product iterationsFrontend APIs powering fast paced product iterations
Frontend APIs powering fast paced product iterationsKarthik Ramgopal
 
Apache Pinot Meetup Sept02, 2020
Apache Pinot Meetup Sept02, 2020Apache Pinot Meetup Sept02, 2020
Apache Pinot Meetup Sept02, 2020Mayank Shrivastava
 
Evolving your Data Access with MongoDB Stitch - Drew Di Palma
Evolving your Data Access with MongoDB Stitch - Drew Di PalmaEvolving your Data Access with MongoDB Stitch - Drew Di Palma
Evolving your Data Access with MongoDB Stitch - Drew Di PalmaMongoDB
 
Microsoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needsMicrosoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needsMicrosoft Tech Community
 
Microsoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needsMicrosoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needsMicrosoft Tech Community
 

Similar to Prisma the ORM that node was waiting for (20)

SPKonferenz 2017 - Introducing SDKs for Microsoft Graph
SPKonferenz 2017 - Introducing SDKs for Microsoft GraphSPKonferenz 2017 - Introducing SDKs for Microsoft Graph
SPKonferenz 2017 - Introducing SDKs for Microsoft Graph
 
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
 
SharePoint Saturday Belgium 2018 - APIs, APIs everywhere!
SharePoint Saturday Belgium 2018 - APIs, APIs everywhere!SharePoint Saturday Belgium 2018 - APIs, APIs everywhere!
SharePoint Saturday Belgium 2018 - APIs, APIs everywhere!
 
APIs, APIs Everywhere!
APIs, APIs Everywhere!APIs, APIs Everywhere!
APIs, APIs Everywhere!
 
SharePoint Saturday Chicago - Everything your need to know about the Microsof...
SharePoint Saturday Chicago - Everything your need to know about the Microsof...SharePoint Saturday Chicago - Everything your need to know about the Microsof...
SharePoint Saturday Chicago - Everything your need to know about the Microsof...
 
Making Things Work Together
Making Things Work TogetherMaking Things Work Together
Making Things Work Together
 
SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!
 
Forge - DevCon 2016: Introduction to Forge 3D Print API Through Sample Applic...
Forge - DevCon 2016: Introduction to Forge 3D Print API Through Sample Applic...Forge - DevCon 2016: Introduction to Forge 3D Print API Through Sample Applic...
Forge - DevCon 2016: Introduction to Forge 3D Print API Through Sample Applic...
 
SharePoint Conference 2018 - Build an intelligent application by connecting i...
SharePoint Conference 2018 - Build an intelligent application by connecting i...SharePoint Conference 2018 - Build an intelligent application by connecting i...
SharePoint Conference 2018 - Build an intelligent application by connecting i...
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3
 
ql.io at NodePDX
ql.io at NodePDXql.io at NodePDX
ql.io at NodePDX
 
MongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDB
 
Silverlight 5 whats new overview
Silverlight 5 whats new overviewSilverlight 5 whats new overview
Silverlight 5 whats new overview
 
SharePoint 2010 Client Object Model
SharePoint 2010 Client Object ModelSharePoint 2010 Client Object Model
SharePoint 2010 Client Object Model
 
Frontend APIs powering fast paced product iterations
Frontend APIs powering fast paced product iterationsFrontend APIs powering fast paced product iterations
Frontend APIs powering fast paced product iterations
 
Soap Toolkit Dcphp
Soap Toolkit DcphpSoap Toolkit Dcphp
Soap Toolkit Dcphp
 
Apache Pinot Meetup Sept02, 2020
Apache Pinot Meetup Sept02, 2020Apache Pinot Meetup Sept02, 2020
Apache Pinot Meetup Sept02, 2020
 
Evolving your Data Access with MongoDB Stitch - Drew Di Palma
Evolving your Data Access with MongoDB Stitch - Drew Di PalmaEvolving your Data Access with MongoDB Stitch - Drew Di Palma
Evolving your Data Access with MongoDB Stitch - Drew Di Palma
 
Microsoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needsMicrosoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needs
 
Microsoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needsMicrosoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needs
 

More from Commit University

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdfBreaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdfCommit University
 
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdfAccelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdfCommit University
 
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...Commit University
 
Commit - Qwik il framework che ti stupirà.pptx
Commit - Qwik il framework che ti stupirà.pptxCommit - Qwik il framework che ti stupirà.pptx
Commit - Qwik il framework che ti stupirà.pptxCommit University
 
Sviluppare da zero una Angular Web App per la PA
Sviluppare da zero una Angular Web App per la PASviluppare da zero una Angular Web App per la PA
Sviluppare da zero una Angular Web App per la PACommit University
 
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...Commit University
 
Decision-making for Software Development Teams - Commit University
Decision-making for Software Development Teams - Commit UniversityDecision-making for Software Development Teams - Commit University
Decision-making for Software Development Teams - Commit UniversityCommit University
 
Component Design Pattern nei Game Engine.pdf
Component Design Pattern nei Game Engine.pdfComponent Design Pattern nei Game Engine.pdf
Component Design Pattern nei Game Engine.pdfCommit University
 
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...Commit University
 
Prototipazione Low-Code con AWS Step Functions
Prototipazione Low-Code con AWS Step FunctionsPrototipazione Low-Code con AWS Step Functions
Prototipazione Low-Code con AWS Step FunctionsCommit University
 
KMM survival guide: how to tackle struggles between Kotlin and Swift
KMM survival guide: how to tackle struggles between Kotlin and SwiftKMM survival guide: how to tackle struggles between Kotlin and Swift
KMM survival guide: how to tackle struggles between Kotlin and SwiftCommit University
 
Da Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazioneDa Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazioneCommit University
 
Orchestrare Micro-frontend con micro-lc
Orchestrare Micro-frontend con micro-lcOrchestrare Micro-frontend con micro-lc
Orchestrare Micro-frontend con micro-lcCommit University
 
Fastify has defeated Lagacy-Code
Fastify has defeated Lagacy-CodeFastify has defeated Lagacy-Code
Fastify has defeated Lagacy-CodeCommit University
 
Alpine.js: the outsider Javascript framework
Alpine.js: the outsider Javascript frameworkAlpine.js: the outsider Javascript framework
Alpine.js: the outsider Javascript frameworkCommit University
 

More from Commit University (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdfBreaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
 
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdfAccelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
 
Slide-10years.pdf
Slide-10years.pdfSlide-10years.pdf
Slide-10years.pdf
 
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
 
Vue.js slots.pdf
Vue.js slots.pdfVue.js slots.pdf
Vue.js slots.pdf
 
Commit - Qwik il framework che ti stupirà.pptx
Commit - Qwik il framework che ti stupirà.pptxCommit - Qwik il framework che ti stupirà.pptx
Commit - Qwik il framework che ti stupirà.pptx
 
Sviluppare da zero una Angular Web App per la PA
Sviluppare da zero una Angular Web App per la PASviluppare da zero una Angular Web App per la PA
Sviluppare da zero una Angular Web App per la PA
 
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
 
Decision-making for Software Development Teams - Commit University
Decision-making for Software Development Teams - Commit UniversityDecision-making for Software Development Teams - Commit University
Decision-making for Software Development Teams - Commit University
 
Component Design Pattern nei Game Engine.pdf
Component Design Pattern nei Game Engine.pdfComponent Design Pattern nei Game Engine.pdf
Component Design Pattern nei Game Engine.pdf
 
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
 
Prototipazione Low-Code con AWS Step Functions
Prototipazione Low-Code con AWS Step FunctionsPrototipazione Low-Code con AWS Step Functions
Prototipazione Low-Code con AWS Step Functions
 
KMM survival guide: how to tackle struggles between Kotlin and Swift
KMM survival guide: how to tackle struggles between Kotlin and SwiftKMM survival guide: how to tackle struggles between Kotlin and Swift
KMM survival guide: how to tackle struggles between Kotlin and Swift
 
Da Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazioneDa Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazione
 
Orchestrare Micro-frontend con micro-lc
Orchestrare Micro-frontend con micro-lcOrchestrare Micro-frontend con micro-lc
Orchestrare Micro-frontend con micro-lc
 
Fastify has defeated Lagacy-Code
Fastify has defeated Lagacy-CodeFastify has defeated Lagacy-Code
Fastify has defeated Lagacy-Code
 
SwiftUI vs UIKit
SwiftUI vs UIKitSwiftUI vs UIKit
SwiftUI vs UIKit
 
Alpine.js: the outsider Javascript framework
Alpine.js: the outsider Javascript frameworkAlpine.js: the outsider Javascript framework
Alpine.js: the outsider Javascript framework
 

Recently uploaded

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 

Recently uploaded (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

Prisma the ORM that node was waiting for

  • 1. Luca Del Puppo - Senior Software Engineer Prisma the ORM that node was waiting for
  • 2. Luca Del Puppo Senior Software Engineer Javascript Enthusiastic Typescript Lover “Youtuber” “Writer” Love sport: running, hiking Love animals
  • 3. Agenda . What is it? . CLI . Data Modeling . Generation . Client . Migration . Deploy . Conclusion
  • 5. Prisma is an open source next-generation ORM. (Node eco-system)
  • 6. Prisma Client Auto-generated and type-safe query builder for Node.js & TypeScript
  • 8. Prisma Studio GUI to view and edit data in your database
  • 11. Hey Bro! Could you talk about interesting stu ? Image by on catalyststu Freepik
  • 12. CLI
  • 15. Prisma File generator client { provider = "prisma-client-js" } datasource db { provider = "postgresql" url = env("DATABASE_URL") } 1 2 3 4 5 6 7 8
  • 18. Schema One le (schema.prisma) Data sources Generators Data model de nition Syntax - PSL (Prisma Schema Language) N.B. Multiple Files is not supported yet
  • 19. Generator & DataSource generator client { provider = "prisma-client-js" } 1 2 3 4 datasource db { 5 provider = "postgresql" 6 url = env("DATABASE_URL") 7 } 8 datasource db { provider = "postgresql" url = env("DATABASE_URL") } generator client { 1 provider = "prisma-client-js" 2 } 3 4 5 6 7 8
  • 20. Models model Ingredient { 1 id Int @id @default(autoincrement()) 2 name String 3 createdAt DateTime @default(now()) 4 updatedAt DateTime @updatedAt 5 pizzaIngredients PizzaIngredient[] 6 7 @@map("INGREDIENTS") 8 } 9 id Int @id @default(autoincrement()) model Ingredient { 1 2 name String 3 createdAt DateTime @default(now()) 4 updatedAt DateTime @updatedAt 5 pizzaIngredients PizzaIngredient[] 6 7 @@map("INGREDIENTS") 8 } 9 createdAt DateTime @default(now()) model Ingredient { 1 id Int @id @default(autoincrement()) 2 name String 3 4 updatedAt DateTime @updatedAt 5 pizzaIngredients PizzaIngredient[] 6 7 @@map("INGREDIENTS") 8 } 9 updatedAt DateTime @updatedAt model Ingredient { 1 id Int @id @default(autoincrement()) 2 name String 3 createdAt DateTime @default(now()) 4 5 pizzaIngredients PizzaIngredient[] 6 7 @@map("INGREDIENTS") 8 } 9 @@map("INGREDIENTS") model Ingredient { 1 id Int @id @default(autoincrement()) 2 name String 3 createdAt DateTime @default(now()) 4 updatedAt DateTime @updatedAt 5 pizzaIngredients PizzaIngredient[] 6 7 8 } 9 model Ingredient { id Int @id @default(autoincrement()) name String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt pizzaIngredients PizzaIngredient[] @@map("INGREDIENTS") } 1 2 3 4 5 6 7 8 9
  • 21. Relations ingredientId Int ingredient Ingredient @relation(fields: [ingredientId], references: [id]) model PizzaIngredient { 1 2 pizzaId Int 3 4 pizza Pizza @relation(fields: [pizzaId], references: [id]) 5 6 @@id([pizzaId, ingredientId]) 7 8 @@map("PIZZA_INGREDIENTS") 9 } 10 pizzaId Int pizza Pizza @relation(fields: [pizzaId], references: [id]) model PizzaIngredient { 1 ingredientId Int 2 3 ingredient Ingredient @relation(fields: [ingredientId], references: [id]) 4 5 6 @@id([pizzaId, ingredientId]) 7 8 @@map("PIZZA_INGREDIENTS") 9 } 10 @@id([pizzaId, ingredientId]) model PizzaIngredient { 1 ingredientId Int 2 pizzaId Int 3 ingredient Ingredient @relation(fields: [ingredientId], references: [id]) 4 pizza Pizza @relation(fields: [pizzaId], references: [id]) 5 6 7 8 @@map("PIZZA_INGREDIENTS") 9 } 10 model PizzaIngredient { ingredientId Int pizzaId Int ingredient Ingredient @relation(fields: [ingredientId], references: [id]) pizza Pizza @relation(fields: [pizzaId], references: [id]) @@id([pizzaId, ingredientId]) @@map("PIZZA_INGREDIENTS") } 1 2 3 4 5 6 7 8 9 10
  • 24.
  • 25. What does it generate? Models Convert Models to Typescript Types Client Query Models (type safe) Constraint to build where clause Constraint to build select Constraint to build insert/update/delete with relation
  • 26. Generated Type export type Ingredient = { id: number name: string createdAt: Date updatedAt: Date } 1 2 3 4 5 6
  • 29. What does it generate? const prisma = new PrismaClient(); 1 await prisma.$connect(); 2 3 const pizza = await prisma.pizza.findUnique({ 4 where: { 5 id: id, 6 }, 7 include: { 8 pizzaIngredients: { 9 include: { 10 ingredient: true, 11 }, 12 }, 13 }, 14 }); 15 await prisma.$connect(); const prisma = new PrismaClient(); 1 2 3 const pizza = await prisma.pizza.findUnique({ 4 where: { 5 id: id, 6 }, 7 include: { 8 pizzaIngredients: { 9 include: { 10 ingredient: true, 11 }, 12 }, 13 }, 14 }); 15 const pizza = await prisma.pizza.findUnique({ where: { id: id, }, include: { pizzaIngredients: { include: { ingredient: true, }, }, }, }); const prisma = new PrismaClient(); 1 await prisma.$connect(); 2 3 4 5 6 7 8 9 10 11 12 13 14 15 const prisma = new PrismaClient(); await prisma.$connect(); const pizza = await prisma.pizza.findUnique({ where: { id: id, }, include: { pizzaIngredients: { include: { ingredient: true, }, }, }, }); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
  • 30. Image by on catalyststu Freepik Crud SQLPrisma Single Multiple Insert create createMany Update update updateMany Delete delete deleteMany Select ndUnique/ ndFirst ndMany Insert/ Update upsert
  • 31. Image by on catalyststu Freepik Aggregation Aggregate Count GroupBy
  • 32. One for each model
  • 34. Image by on catalyststu Freepik Prisma Schema Prisma CLI Database 1. update 2. prisma migrate dev 3. read schema 4. database schema 5. generate migration 6. update database Migration ow
  • 35. Image by on catalyststu Freepik Prisma Schema Prisma CLI Database 2. prisma db pull Introspection ow 1. Change database schema (SQL) 3. read schema 4. database schema 5. Update
  • 36. Limitations MongoDb is not supported (use prisma db push) Switch DB Provider is not supported
  • 37. Seeding Prisma exposes us a command for seeding the db It runs on prisma migrate dev prisma migrate reset manually It can be written in typescript, go, sql… --skip-seed allows skipping
  • 39. N.B. Use a CI/CD ow for your deployment
  • 42. Cons Newby Don’t manage multiple provider concurrency Splitting schema not implemented out-of-the-box (prisma- aurora)
  • 43. Pros Wonderful developer experience Type safe queries Migrations Custom queries Active Community Awesome documentation Core team active in Github and Slack
  • 45. Prisma Series Image by on catalyststu Freepik
  • 46. We are hiring Image by on catalyststu Freepik
  • 47. Luca Del Puppo @puppo92 Luca Del Puppo Puppo_92 @puppo