Does drizzle support `disconnect` relations ?
Does drizzle support
disconnect
feature on relations during update query similar to prisma ?6 Replies
Could you elaborate for those of us not familiar with the prisma feature?
In prisma to remove relations between two sides you can use
disconnect
which is part of the client . It can be used for one to many relationships
https://www.prisma.io/docs/concepts/components/prisma-client/relation-queries#disconnect-a-related-recordPrisma
Relation queries (Concepts)
Prisma Client provides convenient queries for working with relations, such as a fluent API, nested writes (transactions), nested reads and relation filters.
and also connect 😄 I also wonder how it is possible to work with relations in drizzle
Drizzle doesn't extract you away so much from SQL.
Connect and disconnect is an abstraction they invented
In drizzle, you can effectively achieve this by setting the foreign key to null
Let's say you have a
users
table and a posts
table defined like this:
The relations are like this:
You can "disconnect" a post from an user by doing:
Again, connect and disconnect is an abstraction invented by prisma. But its basically the foreign key that connects the modelsI think everyone got too comfortable using prisma lol, but this actually makes sense, atleast we learn some stuff behind the scenes :DD
Thanks for clarifying this. I actually found this out with the basic knowledge of SQL . Also now may be in retrospect I feel
disconnect
and connect
are not so much needed abstractions