Тёмный

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

Sakura Dev
Подписаться 12 тыс.
Просмотров 10 тыс.
50% 1

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

Опубликовано:

 

6 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 82   
@SakuraDev
@SakuraDev 2 месяца назад
❤Please Support me by subscribing to my channel (Sakura Dev) 👉🏻www.youtube.com/@sakuradev?sub_confirmation=1
@JohnCanCode
@JohnCanCode 11 месяцев назад
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"]?
@obinnaezedei856
@obinnaezedei856 9 месяцев назад
This got me started. Thanks
@SakuraDev
@SakuraDev 9 месяцев назад
Thanks. I'm glad it was helpful for you
@arcenciel99
@arcenciel99 23 дня назад
very goood explanation. subscribed!
@SakuraDev
@SakuraDev 23 дня назад
Thank you so much for subscribing! I'm glad you found the explanation helpful. Stay tuned for more content! 😊
@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.
@nickwoodward819
@nickwoodward819 Месяц назад
@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! 😊
@mehmethanifierenler3612
@mehmethanifierenler3612 5 месяцев назад
thanks to thanks
@SakuraDev
@SakuraDev 5 месяцев назад
Thanks
@adehenry9591
@adehenry9591 Год назад
Great job you’re doing 👍🏼
@SakuraDev
@SakuraDev Год назад
Thanks and welcome to the channel 👋
@nickwoodward819
@nickwoodward819 2 месяца назад
also the primaryKey function is now deprecated apparently: `primaryKey({columns:[table.id1, table.id2]})`
@SakuraDev
@SakuraDev 2 месяца назад
Thanks for bringing that to my attention. I will create a new series for Drizzle ORM soon
@nickwoodward819
@nickwoodward819 2 месяца назад
@@SakuraDev This one's definitely great. Appreciate the Adminer knowledge too as Studio is a bit ropey right now
@mfjones7879
@mfjones7879 10 месяцев назад
thank you very much!
@SakuraDev
@SakuraDev 10 месяцев назад
Thanks 🙏
@edwardspresume
@edwardspresume 11 месяцев назад
Thank you for this videos! Are still going to create the video on how to insert a many-to-many relation?
@SakuraDev
@SakuraDev 11 месяцев назад
Thanks for visiting. Yes, I will Complete this course soon.
@PTBKoo
@PTBKoo Год назад
Hi, loved the tutorial series, any updates on the seeding video?
@SakuraDev
@SakuraDev Год назад
Hi, this month I will continue drizzle orm series.
@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
@Johnny-rf4iu
@Johnny-rf4iu 5 месяцев назад
How can I get all the post with a particular category Id??
@bhatvikrant
@bhatvikrant 8 месяцев назад
How can we infer query types?
@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.
@prashlovessamosa
@prashlovessamosa Год назад
Thank you.
@SakuraDev
@SakuraDev Год назад
Thank you for your constant 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.
@user-wc1hn7nw5i
@user-wc1hn7nw5i 9 месяцев назад
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 9 месяцев назад
Because if you want to use the query API, you should use relation function Have nice time 😊
@user-wc1hn7nw5i
@user-wc1hn7nw5i 9 месяцев назад
@@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
@user-wc1hn7nw5i
@user-wc1hn7nw5i 9 месяцев назад
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 9 месяцев назад
@@user-wc1hn7nw5i 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
@dustsucker4704
@dustsucker4704 8 месяцев назад
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?
@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: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-R4ZgTB-1wEg.html
@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 Год назад
Pleade upload more video on drizzle
@SakuraDev
@SakuraDev Год назад
There are more on the way
@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: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-5R2gem0GSmw.html
@korigamik
@korigamik 2 месяца назад
@@SakuraDev cool
@_codesan
@_codesan Год назад
thank you sir
@SakuraDev
@SakuraDev Год назад
Thank you so much for your support 🙏🌷
@nickwoodward819
@nickwoodward819 2 месяца назад
loving the course, but jeeeeeesus drizzles way of dealing with relationships is so verbose compared to what I remember in sequelize
@SakuraDev
@SakuraDev 2 месяца назад
I should take a look at sequelize
@nickwoodward819
@nickwoodward819 2 месяца назад
@@SakuraDev more an ORM than drizzle I think. I did enjoy it, but it's definitely not the 'in' tech
@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()?
Далее
Learn Drizzle ORM in 13 mins (crash course)
14:00
Просмотров 26 тыс.
Drizzle ORM #7-- Inserting Data
19:59
Просмотров 8 тыс.
Modus males sekolah
00:14
Просмотров 9 млн
This is why I love drizzle ORM
4:03
Просмотров 12 тыс.
Get paid with Next.js, Stripe, and Supabase
14:24
Просмотров 1,9 тыс.
Drizzle ORM #6- One To Many Relation ⭐
10:25
Просмотров 10 тыс.
This Drizzle ORM feature is a game changer!
8:11
Просмотров 19 тыс.
Drizzle ORM #5- One To One Relation ⭐
11:40
Просмотров 7 тыс.
Seeding | Drizzle ORM Comprehensive Course | Part-8
28:12
Drizzle ORM #1- Setup - Schema - Migrations ⭐
19:10