Learn Drizzle ORM in 13 mins (crash course)
Вставка
- Опубліковано 25 чер 2024
- Code used in the video: github.com/neondatabase/drizz...
In this video, you'll learn Drizzle ORM. We'll talk about its different components, how to define your database schema, and its SQL-like querying API as well as its relational API
Instructor: / thisismahmoud_ | / mahmoud-codes
→ Try Neon at neon.tech/youtube
→ Neon Discord: neon.tech/discord
→ Follow us on Twitter / neondatabase
→ Star us on GitHub github.com/neondatabase/neon
Make sure to subscribe to the Neon UA-cam channel so you don't miss out on any new videos ✨
00:00 Intro
00:40 Drizzle components
01:07 Project Overview
01:44 How Drizzle works
2:28 Defining the schema using Drizzle ORM
4:26 Generated SQL migrations with Drizzle Kit
8:46 Drizzle ORM's SQL-Like API
11:22 Drizzle ORM's relational API
13:35 Outro - Розваги
If you enjoyed watching this video, make sure to like and subscribe so you don't miss out on any future videos.
If you'd like to learn more about using Drizzle with Preview Environments, check out our previous video: ua-cam.com/video/EOVa68Uviks/v-deo.html
Drizzle ORM Docs: orm.drizzle.team/docs/overview
Neon Serverless Driver: github.com/neondatabase/serverless
This is a great intro thank you! Came here from Fireship's vid.
Excellent and timely tutorial! Would love to see an example of using custom types (adding vector embeddings) through drizzle to Neon too
Glad you found it helpful!
> Would love to see an example of using custom types (adding vector embeddings) through drizzle to Neon too
This is a great idea! Thank you for sharing your feedback
- Mahmoud
Nice file management!
Very helpful for understanding Drizzle, thanks!
We're glad you found it helpful!
very cool and practical. Thanks!
This is the best intro to Drizzle I've ever seen
Nice, I am going to try drizzle now.
Well done!
Only thing I would have loved to see along with this, would be how to retrieve only a few specific columns, rather than everything. :)
If you'd like to do a partial select, you can do it this way
const result = await db.select({
field1: users.id,
field2: users.name,
}).from(users);
orm.drizzle.team/docs/select#partial-select
very informative video and on the target 🎯 love too see more of this types of videos
We're glad you found it helpful!
thank you, this was a nice one, hope there is another how relationships works in drizzle, tyy
Amazing 🔥🔥
Great stuff! It was really informative. I had a slightly different question. 😅
The editor folder icons and theme, which extension are you using? I really liked em!
Would be glad if you could share it.
do you need to close the db connection ?
You look so happy 😊 😊
Awesome content! Just one question which might look stupid : in your package.json, why use bun for migrate/seed and bunx for format/lint with biome being a devDependency ?
Not stupid at all! This is how it's recommended to use in the Biome docs
biomejs.dev/guides/getting-started/#usage
The package is installed in the project so that the editor can format on save. I like including it in the project so that if someone clones the repo they can easily get up and running
- Mahmoud
how can we retrieve large scale json file generated from application like excalidraw ?
What theme and icons are you using for VSCode?
What vscode icon pack are you using?
please help me to generate generic repository pattern using drizzle or dynamic query
Hello Neon
I just wanted to know something. When I generat a new db migrations like you showed it at 4:37 , it is not accepting the syyntax of sql file . I have installed postgres correctly and also not missing any steps in dependencies. Using VS Code . I hope you can help with a reply!!
Hey!
> it is not accepting the syyntax of sql file
Do you mind sharing more details? What kind of issues are you running into? What's the error message?
I tried to ask on their Discord server but no answer.
Does drizzle support add unique constraint based on two columns? `To make a column unique only based on another column, a playlist title is unique per user ID.
Coming from #fireship 😉
If I use neon branches, do I still have to create migrations? Planetscale explains that branches negate migrations so use db push instead of db migrate (for prisma)
Neon doesn't manage migrations for you as of today. So you will need to write them (or generate them depending on your framework of choice) and apply them in a Ci/CD pipeline or before your project's build step.
Merging branches is something we're thinking about. But we don't have an exact ETA
- Mahmoud
Great stiff. How to deal with mysql pools for i stance? Does drizzle open amd close a connection fir each request?
Drizzle doesn't automatically handle the opening and closing of connections for each request. This needs to be handled by the developer, which depends on which database driver they're using
@@neondatabase yes thanks I saw now, using mysql2 pool connection. Loving this ORM
export const db = drizzle(sql)
This line is showing me the error: "Argument of type 'NeonQueryFunction' is not assignable to parameter of type 'NeonQueryFunction'.
Types of property 'transaction' are incompatible.
const sql: NeonQueryFunction = neon(process.env.DATABASE_URL);
this will fix it!
What is ide ?
GitHub Dark theme + the "Symbols" icons extension
- Mahmoud
Why did you choose Hono over Elysiajs. Elysia has been longer in the game and is faster than Hono.
No reason is in particular. Both are awesome!
- Mahmoud
Hono can be deployed to like Workers, Vercel, Node.js etc.... Elysia main focus is bun right and also it is new right?? Also does any hosting support it??