When storing price values in the database using MySQL and defining them as decimals, I encountered errors when trying to retrieve the data using tRPC.
Types of property 'price' are incompatible.
Type 'Decimal | null' is not assignable to type 'number'.
Type 'null' is not assignable to type 'number'.
I searched for a way to define decimal types but could only find references to numbers.
prisma:
model project{
price Decimal? @db.Decimal(19, 4)
...
}
frontend
type projectType = {
price:number
...
}
Even attempting to use BigInt resulted in an error:
Type 'Decimal | null' is not assignable to type 'BigInt'.
To work around the issue, I temporarily used any type. How can I solve this problem?
edit
price Decimal @db.Decimal(19, 4)
Removing the question mark did not resolve the null problem; the error persisted.