DT
Drizzle Team•12mo ago
oke

Drizzle JOIN vs relations

Seems like both Join and relations are equally capable when query data that have relationships. I'd assume that if one is already using Drizzle relations (with with field), then one wouldn't need to use .join(), and vice versa. Is there a reason one should use JOIN vs. relations, or is it personal preference?
2 Replies
Angelelz
Angelelz•12mo ago
The relations API uses several JSON aggregation functions to retrieve related data in an array format. You'll have to decide if the implications of this behavior is good or bad for you. With the joins, you'll need to aggregate the data yourself if you want that format, see here: https://orm.drizzle.team/docs/joins#aggregating-results
Drizzle ORM - next gen TypeScript ORM
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
oke
okeOP•12mo ago
Thanks for the response. Seems like the Relations API is of much better convenience so I will be going forward with that (at the expense of corroding my SQL Joins skill 🥲)
Want results from more Discord servers?
Add your server