Update relationship within 1 query
is it possible to update relationships?
for example i have a one to one relationship between users and notifications but i couldn't find any example of how i could update the notifications of a user in 1 query
same question goes for many to many relationships
lets say i have a many to many between users and interests
i want to update the user attributes and the interests of the user
do i have to:
1. update user attributes
2. delete the current interests of the user from the association table
3. insert updated interests of the user
2 Replies
You can't update several tables at the same time in SQL
Remember users and notifications are different tables. Same for the many to many, those are different tables, and have to be updated in separate queries
The correct SQL/Drizzle way to do this is within a transaction
You can read about how to do it in drizzle here:
https://orm.drizzle.team/docs/transactions
Transactions – DrizzleORM
Drizzle ORM | %s