Amit
10/06/2021, 12:46 PMJson?
field (optional JSON), I can't use undefined
because it then just treats it like there's no key, and I can't use null
because then Prisma is angry with me.
Can someone please help me update an object in such way?
It's not a key within the JSON, but literally I want to update a previously updated JSON (say {"a": "b"}
) to NULLRyan
10/06/2021, 12:49 PMAmit
10/06/2021, 3:14 PMprisma.something.update({
where: ...
data: {
jsonField: null
}
}
The type is not accepted there, it was on 2.24. I'll investigate more anyway and will update in here, thanks a lot for the quick responseRyan
10/07/2021, 4:27 AMAmit
10/07/2021, 6:13 AMRyan
10/07/2021, 6:15 AMAmit
10/07/2021, 10:41 AMAmit
10/07/2021, 10:41 AMPrisma.DbNulll
as the valueAmit
10/07/2021, 10:42 AMnull
, e.g.:
if (somethingRemoved) {
await prisma.obj.update({
where: id.
data: {
jsonColumn: Prisma.DbNull
}
})
}
Amit
10/07/2021, 10:45 AMindex.d.ts
) type is:
export type MyObject = {
...
jsonColumn?: NullableJsonNullValueInput | InputJsonValue
...
}
Ryan
10/07/2021, 11:09 AMAmit
10/07/2021, 11:09 AMAmit
10/07/2021, 11:09 AMUPDATE
statements?Amit
10/07/2021, 11:11 AMDbNull
)Ryan
10/07/2021, 11:15 AMAmit
10/07/2021, 11:30 AM