Drizzle ORM #7- Many-To-Many Relations ⭐

  Рет қаралды 9,980

Sakura Dev

Sakura Dev

Күн бұрын

Many-To-Many Relations has Always been tricky but In this episode of Drizzle ORM Comprehensive Course, You will Master how to create Many-To-Many Relations with Drizzle ORM.
📖 Drizzle ORM Playlist: • Drizzle ORM Comprehens...
🎞️ Drizzle ORM: #: • Drizzle ORM #1- Setup ...
🎞️ Drizzle ORM: #2: • Drizzle ORM #2- SQL Ty...
🎞️ Drizzle ORM: # 3: • Drizzle ORM #3- Write ...
🎞️ Drizzle ORM #4: • Drizzle ORM #4- All Qu...
🎞️ Drizzle ORM #5: • Drizzle ORM #5- One To...
🎞️ Drizzle ORM #6 : • Drizzle ORM #6- One To...
🎞️ Drizzle ORM #7: • Drizzle ORM #7- Many-T...
--------------------------------------------------
🚀 GitHub Repo (Don't Forget to Give a ⭐): github.com/vah...
💖 My Twitter for more insights: / sakura_dev_web
--------------------------------------------------
Other videos you might like:
Type Safety and Auto Completion for ENV Variables in NextJS: • Type Safety For ENV Va...
#DrizzleOrm #Orm #nodejs #nextjs #typescript

Пікірлер: 82
@SakuraDev
@SakuraDev 2 ай бұрын
❤Please Support me by subscribing to my channel (Sakura Dev) 👉🏻www.youtube.com/@sakuradev?sub_confirmation=1
@JohnCanCode
@JohnCanCode Жыл бұрын
Is there any way to get postCategories from this [{category: {name: "sport"}}, ...] to this [{name: sport}]?
@djesoproducer5336
@djesoproducer5336 Жыл бұрын
Thank you so much! I can't wait to see upcoming sections of the course 😍
@SakuraDev
@SakuraDev Жыл бұрын
Hi, Welcome to my channel . I will Create more episode for this course
@rdx86
@rdx86 11 ай бұрын
Great video! How can you retrieve the postCategories as a list of strings i.e. ["Sport", "Economics"]?
@gautam_vaishnav
@gautam_vaishnav Жыл бұрын
You are a great teacher, ♥ I am waiting for next sections.
@SakuraDev
@SakuraDev Жыл бұрын
I'm glad you're enjoying the content! Stay tuned for more in the upcoming sections.
@obinnaezedei856
@obinnaezedei856 9 ай бұрын
This got me started. Thanks
@SakuraDev
@SakuraDev 9 ай бұрын
Thanks. I'm glad it was helpful for you
@adehenry9591
@adehenry9591 Жыл бұрын
Great job you’re doing 👍🏼
@SakuraDev
@SakuraDev Жыл бұрын
Thanks and welcome to the channel 👋
@arcenciel99
@arcenciel99 Ай бұрын
very goood explanation. subscribed!
@SakuraDev
@SakuraDev Ай бұрын
Thank you so much for subscribing! I'm glad you found the explanation helpful. Stay tuned for more content! 😊
@mfjones7879
@mfjones7879 10 ай бұрын
thank you very much!
@SakuraDev
@SakuraDev 10 ай бұрын
Thanks 🙏
@mehmethanifierenler3612
@mehmethanifierenler3612 6 ай бұрын
thanks to thanks
@SakuraDev
@SakuraDev 6 ай бұрын
Thanks
@edwardspresume
@edwardspresume Жыл бұрын
Thank you for this videos! Are still going to create the video on how to insert a many-to-many relation?
@SakuraDev
@SakuraDev Жыл бұрын
Thanks for visiting. Yes, I will Complete this course soon.
@prashlovessamosa
@prashlovessamosa Жыл бұрын
Thank you.
@SakuraDev
@SakuraDev Жыл бұрын
Thank you for your constant support 🌷
@Johnny-rf4iu
@Johnny-rf4iu 6 ай бұрын
How can I get all the post with a particular category Id??
@PTBKoo
@PTBKoo Жыл бұрын
Hi, loved the tutorial series, any updates on the seeding video?
@SakuraDev
@SakuraDev Жыл бұрын
Hi, this month I will continue drizzle orm series.
@bhatvikrant
@bhatvikrant 9 ай бұрын
How can we infer query types?
@nickwoodward819
@nickwoodward819 2 ай бұрын
@10:51 - how are you querying categories 'with: {posts:true}', without having to reference the join table? shouldn't it be: `await db.query.categories.findFirst({ with:{ postOnCategories: { with: { posts:true } } } })` I literally can't seem to avoid referencing the otherside of the many to many relationship without the join table? Still a great video, I keep coming back to it over the docs! :)
@SakuraDev
@SakuraDev Ай бұрын
Hey @nickwoodward819, with Drizzle ORM, you typically need to reference the join table for many-to-many relationships. So your approach using postOnCategories is correct. Thanks for catching that, and I'm glad the video is helpful! 😊
@dustsucker4704
@dustsucker4704 9 ай бұрын
I have one question, I cant use the query stuff I have a document Table named document, and it's in the database with the migration tool. Now i try to use db.query.document and it can't find the document table but why? i have my schema split up in multiple files because it's easier to manage and tried to import it into the drizzle(connection , {schema}) and couldn't make it work do you have any tips on how to handle the multi file mode?
@_codesan
@_codesan Жыл бұрын
thank you sir
@SakuraDev
@SakuraDev Жыл бұрын
Thank you so much for your support 🙏🌷
@lenghak_hok
@lenghak_hok Жыл бұрын
Hello! I am here again. I was wondering how we can implement the prepare statement for updating data with drizzle. I would be obliged if you could provide us some solutions. Thank u.
@SakuraDev
@SakuraDev Жыл бұрын
Hi, In the upcoming sections I will explain that.
@nickwoodward819
@nickwoodward819 3 ай бұрын
also the primaryKey function is now deprecated apparently: `primaryKey({columns:[table.id1, table.id2]})`
@SakuraDev
@SakuraDev 3 ай бұрын
Thanks for bringing that to my attention. I will create a new series for Drizzle ORM soon
@nickwoodward819
@nickwoodward819 3 ай бұрын
@@SakuraDev This one's definitely great. Appreciate the Adminer knowledge too as Studio is a bit ropey right now
@Manish___Choudhary
@Manish___Choudhary Жыл бұрын
How to fetch those posts which don't have any category
@SakuraDev
@SakuraDev Жыл бұрын
In my opinion the best way to fetch these edge cases is using join func from drizzle.
@steel1004
@steel1004 11 ай бұрын
in need to keep schema by table separately in one folder schemas with realtions between them, but drizzle cannt them if i wanna relations i need place all of them to one file
@SakuraDev
@SakuraDev 11 ай бұрын
Just export tables from their files and import them in relation file
@sandeepbhaiya6658
@sandeepbhaiya6658 Жыл бұрын
Pleade upload more video on drizzle
@SakuraDev
@SakuraDev Жыл бұрын
There are more on the way
@F.E-p3s
@F.E-p3s 10 ай бұрын
The .refernces() function is actually all I needed in the past to define relations. Why do I need these unhandy relations objects for every relation?
@SakuraDev
@SakuraDev 10 ай бұрын
Because if you want to use the query API, you should use relation function Have nice time 😊
@F.E-p3s
@F.E-p3s 10 ай бұрын
@@SakuraDev Thank you, I will have a look at relation function. Interesting they exists because the official documentation doesnt talk about them existing. Still not sure about the need of these relation objects rather than being an absolute syntactical obsolete nonsense. But I guess Ill figure that out when actually using your mentioned relation functions
@F.E-p3s
@F.E-p3s 10 ай бұрын
Ok, so after digging some time I found it out: Defining relations using these relation object is optional and represent a higher level of obstraction for using relations. Its useful for: 1.)When your DB doesnt support foreign keys 2.) You are coming from e.g. prisma and want to use a higher level abstraction of querying for relations. So to be exact its just a higher abstraction layer that is by no means necessary unless you work with a db like PlanetScale that does not support foreign keys. Querying relations with them just includes the related data right into the result object rather than returning related data in a seperate array. Its kinda strange that drizzle behaves like this but now I know the exact difference and maybe this post will help other ppl that just dont get it as me before
@SakuraDev
@SakuraDev 10 ай бұрын
@@F.E-p3s WOW 😲 that's a comprehensive explanation. Thanks for sharing your thoughts 🙏🙏
@obinnaezedei856
@obinnaezedei856 9 ай бұрын
At first, I felt the relations object helps the typescripting during queries, provides the objects in the with: param out of the box, and by all means optional. If you don't include the relations function, you will have to struggle with the typescripting if you are using typescript, else, you flow with the normal js
@korigamik
@korigamik 2 ай бұрын
how do you insert into this realtion?
@SakuraDev
@SakuraDev 2 ай бұрын
hi, in this video I teach how to insert with many-many relations: kzbin.info/www/bejne/a4OVmJijZayGo9k
@korigamik
@korigamik 2 ай бұрын
@@SakuraDev cool
@nickwoodward819
@nickwoodward819 3 ай бұрын
loving the course, but jeeeeeesus drizzles way of dealing with relationships is so verbose compared to what I remember in sequelize
@SakuraDev
@SakuraDev 3 ай бұрын
I should take a look at sequelize
@nickwoodward819
@nickwoodward819 3 ай бұрын
@@SakuraDev more an ORM than drizzle I think. I did enjoy it, but it's definitely not the 'in' tech
@LucaStasio
@LucaStasio Жыл бұрын
Many to Many does not really work, at least, in an orm-ish way... the select returns the associations table rows and not the associated category object. It a bit messy to work with those multiple "with" and "columns". But, it is my own opinion.
@SakuraDev
@SakuraDev Жыл бұрын
In my opinion using Joins in drizzle is better in case of many to many rels
@LucaStasio
@LucaStasio Жыл бұрын
@@SakuraDev yep! You're right. I also think so. The point here (for me) is: why Drizzle is named "orm"? It is a very good Query Builder, but it's a query builder and not an ORM. Even this "relational queries" functionalities are just a way to write down joins in a more fashionable way, but that's it, they don't map related objects like an ORM should do.
@SakuraDev
@SakuraDev Жыл бұрын
@@LucaStasio Yes, in this point of view, TypeORM for example, is a real ORM. But drizzle orm is more like a query builder.
@Antebios
@Antebios 2 ай бұрын
How can you specify a filter???
@SakuraDev
@SakuraDev 2 ай бұрын
Hi, you can watch this video for query filters: kzbin.info/www/bejne/iGW9mId4Ypaqe8k
@Antebios
@Antebios 2 ай бұрын
@@SakuraDev That video is NOT for Query filters. Instead it is for Select filters. I want to see examples of many-to-many relationship Queries WITH filters. It's not working as expected.
@SakuraDev
@SakuraDev 2 ай бұрын
@@Antebios Ok Then, I will Give you a code example. just leave another comment so that I don't forget to that.
@sandeepbhaiya6658
@sandeepbhaiya6658 Жыл бұрын
Prisma vs drizzle?
@SakuraDev
@SakuraDev Жыл бұрын
I will create it in next few days
@JohnCanCode
@JohnCanCode Жыл бұрын
Great vid. Im watching, following along, and going back over certain parts to see why my `db.query` only has `$drizzleTypeError`
@SakuraDev
@SakuraDev Жыл бұрын
Thanks. Have you run migrations?
@JohnCanCode
@JohnCanCode Жыл бұрын
@@SakuraDev is that required while testing? atm, I `db:push`, and delete my `db.sqlite` file when I have errors. Thanks for the response.
@SakuraDev
@SakuraDev Жыл бұрын
@@JohnCanCode it is not required but I wanted to know if you have configured the db without any error.
@JohnCanCode
@JohnCanCode Жыл бұрын
@@SakuraDev cool, if this answers your question, I can successfully push changes to my sqlite db
@SakuraDev
@SakuraDev Жыл бұрын
@@JohnCanCode so It should not give you error. Can you run db.select()?
Drizzle ORM #5- One To One Relation ⭐
11:40
Sakura Dev
Рет қаралды 7 М.
Drizzle ORM #6- One To Many Relation ⭐
10:25
Sakura Dev
Рет қаралды 10 М.
escape in roblox in real life
00:13
Kan Andrey
Рет қаралды 81 МЛН
小丑在游泳池做什么#short #angel #clown
00:13
Super Beauty team
Рет қаралды 44 МЛН
Остановили аттракцион из-за дочки!
00:42
Victoria Portfolio
Рет қаралды 3,5 МЛН
Drizzle ORM in NestJS: Step By Step Crash Course
1:02:42
Sakura Dev
Рет қаралды 1,4 М.
Complex Schema Design with Drizzle ORM | Common Patterns
45:55
Drizzle ORM #1- Setup - Schema - Migrations ⭐
19:10
Sakura Dev
Рет қаралды 32 М.
Learn Drizzle ORM in 13 mins (crash course)
14:00
Neon
Рет қаралды 28 М.
UUID vs INT: What’s Better For Your Primary Key?
9:40
Database Star
Рет қаралды 38 М.
Seeding | Drizzle ORM Comprehensive Course | Part-8
28:12
Sakura Dev
Рет қаралды 4 М.
Drizzle vs Prisma: Which ORM is right for YOU?
5:59
Kodaps Academy
Рет қаралды 8 М.
escape in roblox in real life
00:13
Kan Andrey
Рет қаралды 81 МЛН