example schema
taxAmount!: Decimal | null;
and this sample code to insert db
prisma.taxAmount = model.taxAmount ? parseFloat(model.taxAmount) : undefined;
and this error
Type 'Decimal | 'undefined' | null' is not assignable to type 'Decimal | null'.
Type 'undefined' is not assignable to type 'Decimal | null'.ts(2322) (property) DeliveryDetailsPrisma.taxAmount: Decimal | null
how to fix it ?
CodePudding user response:
Are you sure you can't do with assigning null
instead of undefined
? The taxAmount
field seems to be expecting Decimal
or null
, not undefined
. Moreover, Null and undefined have separate meanings in the context of Prisma.
If you try the following instead, it should work fine.
prisma.taxAmount = model.taxAmount ? parseFloat(model.taxAmount) : null;