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:
await prisma.item.create({
data: {
order: 1,
sectionId: "1",
itemTags: {
create: [
{
tagId: "1",
},
],
},
},
});await prisma.item.create({
data: {
order: 1,
sectionId: "1",
itemTags: {
create: [
{
tagId: "1",
},
],
},
},
});But this doesn't:
await prisma.item.createMany({
data: [
{
order: 1,
sectionId: "1",
itemTags: {
create: [
{
tagId: "1",
},
],
},
},
],
});await prisma.item.createMany({
data: [
{
order: 1,
sectionId: "1",
itemTags: {
create: [
{
tagId: "1",
},
],
},
},
],
});Right now my prisma schema looks sort of like this:
model Tag {
...stuff
itemTags ItemTag[]
}
model ItemTag {
id String @default(cuid())
itemId String
tagId String
item Item @relation(fields: [itemId], references: [id])
tag Tag @relation(fields: [tagId], references: [id])
@@id([itemId, tagId])
}
model Item {
...stuff
itemTags ItemTag[]
}model Tag {
...stuff
itemTags ItemTag[]
}
model ItemTag {
id String @default(cuid())
itemId String
tagId String
item Item @relation(fields: [itemId], references: [id])
tag Tag @relation(fields: [tagId], references: [id])
@@id([itemId, tagId])
}
model Item {
...stuff
itemTags ItemTag[]
}