What's the best way to bulk insert with a many-to-many relationship (posts & categories) in prisma?

What's the best way to bulk insert with a many-to-many relationship (posts & categories) in prisma?
9 Replies
AdmiralGeneralAladeen
I have a large amount of posts I need to seed into the database, but there doesn't seem to be a way to do that with a many-to-many relationship like categories
paul
paul2y ago
how slow is it to do them in a loop? (and what is this for? testing I guess?)
AdmiralGeneralAladeen
very slow, there are about 30k articles posts to push not for testing, im transferring over data from to from a legacy site
paul
paul2y ago
ok, if 30k and it's a one-time job, I might just say do it the slow way. If it runs a long time it runs a long time. But also since this is a one-time job, consider maybe dropping out of prisma and using SQL if you think that will let you get done faster
haris
haris2y ago
do u have a many to many set up in ur prisma schema already or no If you have the schema and etc all done, then just use a createMany, which is a single SQL statement and faster than doing many creates
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
AdmiralGeneralAladeen
\so you're basically just doing putting the foreign key in manually?
Want results from more Discord servers?
Add your server