Query for Prisma like insert in multiple joined tables
Is there a way to achieve insert in multiple tables joined by foreign keys in one query like Prisma?
Or subsequent inserts in a transaction is the way?
{
orderStatus: OrderStatus.CART,
organization: {
connect: {
id: orgId
}
},
products: {
create: {
price: price,
product: {
connect: {
id: product.id
}
},
quantity: orderProduct.quantity,
taxPercent: taxPercent,
variants: {
createMany: {
data: variantsOnOrder
}
}
}
}
}{
orderStatus: OrderStatus.CART,
organization: {
connect: {
id: orgId
}
},
products: {
create: {
price: price,
product: {
connect: {
id: product.id
}
},
quantity: orderProduct.quantity,
taxPercent: taxPercent,
variants: {
createMany: {
data: variantsOnOrder
}
}
}
}
}Or subsequent inserts in a transaction is the way?