:wave: What are the proper patterns to update the ...
# orm-help
k
👋 What are the proper patterns to update the database entities relations within rest API? I.e I want to remove the
amenity
from particular
chalet
Is this is how I do it?
Copy code
await prisma.chalet.update({ where: { id }, data:{ amenities: { disconnect:{ id }}}});
Can/should I do it other way around? (disconnecting chalet from amenity)? I'm confused What my rest api route should look like? do I target
chalet
or
amenity
? My sample schema:
Copy code
model Chalet {
  id           String    @id @unique @default(cuid())
  bookings     Booking[]
  reviews      Review[]
  amenities    Amenity[]
}
y
From the db perspective I don't believe it matters. Just do what makes sense to you and can fulfill your business logic the best