CreateMany not allowing me to create nested M:N entities
I've got a situation where this query works:
But this doesn't:
Right now my prisma schema looks sort of like this:
3 Replies
I am currently using prisma with postgres
If I’m understanding correctly, you’re trying to create many items and also one or more item tags for those items. That currently isn’t possible with Prisma:
https://www.prisma.io/docs/orm/reference/prisma-client-reference#createmany (see under remarks)
A workaround is to create many items and then make a second call (perhaps in a transaction) to create tags. Similar to this example: https://www.prisma.io/docs/orm/prisma-client/queries/relation-queries#using-nested-createmany
Relation queries (Concepts) | Prisma Documentation
Prisma Client provides convenient queries for working with relations, such as a fluent API, nested writes (transactions), nested reads and relation filters.
Prisma Client API | Prisma Documentation
API reference documentation for Prisma Client.
Dang that’s going to be a surprisingly painful refactor for me, right now this is a small piece of the puzzle in a large deep clone
So restaurants have menus have section groups have sections have items
But items have a many to many with tags 😂
I’ve got a strategy but it’s going to be pretty 🤮