prisma-client-go icon indicating copy to clipboard operation
prisma-client-go copied to clipboard

Linking multiple many-to-many in one go

Open fragdance1 opened this issue 2 years ago • 3 comments

In the typescript client we are able to do something like: bild

Where we send in an array of models to respective field (genre, cast etc).

I saw some discussion in #207 but it doesn't really apply to my needs.

What I've done locally is to add a statement Connect that takes and array of the correct model and creates links automatically.

This is how I use it: First create all the arrays (for instance genre) bild

Then send it in a Connect statement

bild

Is this something that could be of use?

fragdance1 avatar Jul 04 '22 17:07 fragdance1

How is this different from using .Link() and appending the to the query params? Wouldn't that work with the existing .Link()? Except for that you wouldn't use a models array but a params with the id array

steebchen avatar Jul 05 '22 15:07 steebchen

It's mostly a convenience thing (not having to iterate over the created genres to extract id in the app). In the back it does indeed add the genre ids in an array

fragdance1 avatar Jul 05 '22 15:07 fragdance1

Hm ok. Not really important IMO but let's keep it open and I'll think about it later

steebchen avatar Jul 05 '22 15:07 steebchen