Dev__
02/25/2022, 3:47 PMupsert
a record in the database where the orderId
must not have a value.
.upsert({
create: {
...
},
update: {
...
},
where: {
id,
orderId: undefined
}
})
orderId
is possible undefined
because its an optional relation. how can I say in the where
that is must match an id
and where `orderId`'s value is empty. afaik undefined
means do nothing, but I need it to do somethingDev__
02/25/2022, 3:50 PMnull
i get this: Type 'null' is not assignable to type 'string | undefined'.ts(2322)
. This is how its defined in my modal
orderId String? @unique @db.VarChar(255)
zomars
02/25/2022, 3:54 PMlet where = {
id,
}
if (orderId) where.orderId = orderId;
....
.upsert({
create: {
...
},
update: {
...
},
where,
})
Dev__
02/25/2022, 3:55 PMorderId
NOT undefined
Dev__
02/25/2022, 3:56 PMwhere: {
id,
orderId: null
}
Dev__
02/25/2022, 3:56 PMDev__
02/25/2022, 3:56 PMnull
doesnt workCelestine
02/25/2022, 7:08 PMDev__
02/25/2022, 7:10 PMCelestine
02/25/2022, 7:12 PMDev__
02/25/2022, 7:29 PMmodel GenericOrder {
...
orderId String? ...
order Order? relation...
}
model Order {
...
genericOrders GenericOrder[]
}
Celestine
02/25/2022, 7:36 PMorderId: string | null
in the prisma client type definitions.
It seems instead you have “string | undefined” for some reason.
Can you confirm what is in the prisma client type definitionDev__
02/25/2022, 7:39 PMDev__
02/25/2022, 7:39 PMDev__
02/25/2022, 7:39 PMCelestine
02/25/2022, 7:41 PMGenericOrderWhereUniqueInput
Celestine
02/25/2022, 7:43 PMDev__
02/25/2022, 7:45 PMDev__
02/25/2022, 7:45 PM