Fireship · @fireship
Drizzle ORM in 100 Seconds
Uploaded February 29, 2024 · Length 2:54
Summary
Drizzle ORM explained: a lightweight, type-safe object relational mapping for databases like MySQL, PostgreSQL, and SQL Light.
- drizzle orm
- object relational mapping
- typescript database
- sql light
- postgressql
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
drizzle om a lightweight set of tools
- 0:02
that makes type safe object relational
- 0:04
mapping with your favorite relational
- 0:06
database fun again most apps in the real
- 0:08
world rely on databases like MySQL
- 0:11
postgressql and SQL light to store their
- 0:13
critical user data but working with raw
- 0:15
SQL can be painful and even
- 0:17
life-threatening when you screw up over
- 0:19
the decades hundreds of libraries have
- 0:20
been built to abstract away SQL code to
- 0:23
hide its complexity inside your favorite
- 0:25
objectoriented programming language this
- 0:27
technique is called object relational
- 0:29
mapping it's great and null but can
- 0:31
often bring unnecessary performance
- 0:32
overhead and cause leaky abstractions
- 0:35
because the developers have no idea how
- 0:36
their underlying SQL code actually works
- 0:39
drizzle is an omm that takes the
- 0:41
opposite approach it provides an API and
- 0:42
typescript that closely matches the
- 0:44
native underly SQL code this gives you
- 0:47
the benefits of type safety and
- 0:48
intellisense without all the crazy
- 0:50
abstractions but how is that possible
- 0:52
when every database is different instead
- 0:54
of trying to jam everything into a
- 0:55
single API drizzle provides dedicated
- 0:57
adapters for each one of them along with
- 0:59
dedicated tools for popular Cloud hosts
- 1:01
like RDS and neon but if this code looks
- 1:04
too raw and uncensored for you it also
- 1:06
provides an optional Prisma likee query
- 1:08
API that keeps your data fetching and
- 1:10
join code concise and readable in
- 1:12
addition it provides an optional CLI for
- 1:14
handling database migrations called
- 1:16
drizzle kit but the cherry on top is
- 1:18
drizzle Studio A guey you can run
- 1:20
locally to manage your data to get
- 1:21
started you'll first need a relational
- 1:23
database I'm going with neon my go-to
- 1:25
pick for a postgress database and the
- 1:27
sponsor of today's video neon is awesome
- 1:29
because it's easy to use there's a
- 1:31
generous free tier and it even has a
- 1:33
fast serverless driver with a drizzle
- 1:35
adapter you don't even need to install
- 1:36
postgress locally just create a new
- 1:38
database on the dashboard both drizzle
- 1:40
and neon are designed to run on any
- 1:42
JavaScript runtime like node.js bun and
- 1:44
Dino as well as Edge run times like
- 1:46
cloudflare workers now install drizzle
- 1:48
and your database driver then connect to
- 1:50
the database in your typescript code we
- 1:52
could start making queries now but we
- 1:53
don't have any data yet first we need a
- 1:55
schema create a schema file then Define
- 1:57
tables with the PG table function each
- 1:59
table table has a name followed by


