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

JSP Components and Directives.pdf
JSP Components and Directives.pdfJSP Components and Directives.pdf
JSP Components and Directives.pdfArumugam90
 
Django for Beginners
Django for BeginnersDjango for Beginners
Django for BeginnersJason Davies
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and DjangoMichael Pirnat
 
MariaDB Galera Cluster presentation
MariaDB Galera Cluster presentationMariaDB Galera Cluster presentation
MariaDB Galera Cluster presentationFrancisco Gonçalves
 
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...Doug Jones
 
Deep Dive into MySQL InnoDB Cluster Read Scale-out Capabilities.pdf
Deep Dive into MySQL InnoDB Cluster Read Scale-out Capabilities.pdfDeep Dive into MySQL InnoDB Cluster Read Scale-out Capabilities.pdf
Deep Dive into MySQL InnoDB Cluster Read Scale-out Capabilities.pdfMiguel Araújo
 
EWD 3 Training Course Part 4: Installing & Configuring QEWD
EWD 3 Training Course Part 4: Installing & Configuring QEWDEWD 3 Training Course Part 4: Installing & Configuring QEWD
EWD 3 Training Course Part 4: Installing & Configuring QEWDRob Tweed
 
Locking the Throneroom 2.0
Locking the Throneroom 2.0Locking the Throneroom 2.0
Locking the Throneroom 2.0Mario Heiderich
 
Oscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simpleOscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simpleMartin Odersky
 
Vue.js + Django - configuración para desarrollo con webpack y HMR
Vue.js + Django - configuración para desarrollo con webpack y HMRVue.js + Django - configuración para desarrollo con webpack y HMR
Vue.js + Django - configuración para desarrollo con webpack y HMRJavier Abadía
 
Web Application Development using PHP and MySQL
Web Application Development using PHP and MySQLWeb Application Development using PHP and MySQL
Web Application Development using PHP and MySQLGanesh Kamath
 

What's hot (20)

JSP Components and Directives.pdf
JSP Components and Directives.pdfJSP Components and Directives.pdf
JSP Components and Directives.pdf
 
What is an API?
What is an API?What is an API?
What is an API?
 
Django for Beginners
Django for BeginnersDjango for Beginners
Django for Beginners
 
Single Page Applications
Single Page ApplicationsSingle Page Applications
Single Page Applications
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and Django
 
CSS Grid Layout
CSS Grid LayoutCSS Grid Layout
CSS Grid Layout
 
Nodejs buffers
Nodejs buffersNodejs buffers
Nodejs buffers
 
React workshop
React workshopReact workshop
React workshop
 
MariaDB Galera Cluster presentation
MariaDB Galera Cluster presentationMariaDB Galera Cluster presentation
MariaDB Galera Cluster presentation
 
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
 
Deep Dive into MySQL InnoDB Cluster Read Scale-out Capabilities.pdf
Deep Dive into MySQL InnoDB Cluster Read Scale-out Capabilities.pdfDeep Dive into MySQL InnoDB Cluster Read Scale-out Capabilities.pdf
Deep Dive into MySQL InnoDB Cluster Read Scale-out Capabilities.pdf
 
EWD 3 Training Course Part 4: Installing & Configuring QEWD
EWD 3 Training Course Part 4: Installing & Configuring QEWDEWD 3 Training Course Part 4: Installing & Configuring QEWD
EWD 3 Training Course Part 4: Installing & Configuring QEWD
 
Node.js
Node.jsNode.js
Node.js
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
React js
React jsReact js
React js
 
Rust
RustRust
Rust
 
Locking the Throneroom 2.0
Locking the Throneroom 2.0Locking the Throneroom 2.0
Locking the Throneroom 2.0
 
Oscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simpleOscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simple
 
Vue.js + Django - configuración para desarrollo con webpack y HMR
Vue.js + Django - configuración para desarrollo con webpack y HMRVue.js + Django - configuración para desarrollo con webpack y HMR
Vue.js + Django - configuración para desarrollo con webpack y HMR
 
Web Application Development using PHP and MySQL
Web Application Development using PHP and MySQLWeb Application Development using PHP and MySQL
Web Application Development using PHP and MySQL
 

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

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Recently uploaded (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 

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