Hi, I'm having some TS errors in nested writes that I can't figure how to resolve.
Here is the function :
const savePayment = await prisma.payments.create({
data: {
id: responseObj.id,
userId: responseObj.customer.external_id,
orderId: 1,
amount: responseObj.amount,
// on this nested write, I'd like to connect only to records from my bank
// response code table where all the codes and description has been already
//set. But a simple connect throws an error, so I tried to be smart and
// create a null code
responseCode: {
connectOrCreate: {
where: {
code: responseObj.response ? responseObj.response : "000",
},
create: {
code: "000",
description: "Null",
}
}
},
status: responseObj.status ? responseObj.status as Status : Status.NULL,
createdAt: date,
// on this nested write, I create a card unless it already exists in the db
card: {
connectOrCreate: {
where: {
id: responseObj.card.id,
},
create: {
id: responseObj.card.id,
last4: responseObj.card.last4,
brand: responseObj.card.brand,
expMonth: responseObj.card.exp_month,
expYear: responseObj.card.exp_year,
name: responseObj.card.name,
userId: responseObj.customer.external_id,
createdAt: date,
}
},
}
},
include: {
responseCode: true,
cardUsed: true
}
});
more below...