Gustav Walter
05/30/2021, 11:55 AMconst response = await prisma.product.findUnique({
where: {
name: name,
},
});
and it's complaining about the name type when I try to build, please look at the attached image.
Now it's complaining about the type, the name was originally a string but I changed it to any, but I still can't seem to get it to work.
My model for the product table is:
model Product {
id Int @id @default(autoincrement())
name String @unique
price Int
orderItems OrderItem[]
}
and the error message is:
Type error: Type '{ name: any; }' is not assignable to type 'ProductWhereUniqueInput'.
I'm assuming it has something to do with the @unique part in the table and the type around it.
If anyone know how to solve this, feel free to contact me! 🙂
Thanks
//GustavТоше
05/30/2021, 11:59 AMGustav Walter
05/30/2021, 12:02 PMorders.map(async (name: any) => {
const response = await prisma.product.findUnique({
where: {
name: name,
},
});
if (response?.id) {
await prisma.orderItem.create({
data: {
amount: bodyData.order.length,
productId: response.id,
orderId: order.id,
},
});
}
});Gustav Walter
05/30/2021, 12:03 PMLars Ivar Igesund
05/30/2021, 1:31 PMRyan
05/31/2021, 6:53 AM