Ludde Bror
03/20/2022, 8:13 AMmodel Order {
id Int @id @unique @default(autoincrement())
products Product[] @relation(references: [id])
}
model Product {
id Int @id @unique @default(autoincrement())
orders Order[] // Why do I need this here? I don't really care about this, I only care about the above, products in an order. Can I get rid of this line somehow?
}
Another thing, how can I reference a product in an order entry, and at the same time set some additional information about it, such as the quantity of a referenced product?andrewicarlson
03/21/2022, 3:51 PMconst update = await prisma.order.update({
where: {
id: 1, // Order ID
},
data: {
products: {
update: {
where: {
id: 2 // Product ID
},
data: {
your_updated_field: 'Updated value'
}
}
}
}
})