Supporting decimals in prisma schema
My schema has fields like so:
Then when I write an operation to fetch Payment rules, I get the following error:
How to resolve??
model PaymentRule {
id String @id @default(uuid())
venueId String
venue Venue @relation(fields: [venueId],
pricePerHour Decimal
}model PaymentRule {
id String @id @default(uuid())
venueId String
venue Venue @relation(fields: [venueId],
pricePerHour Decimal
}Then when I write an operation to fetch Payment rules, I get the following error:
export const getVenueById: GetVenueById<
GetVenueByIdPayload,
(Venue & { spaces: Space[]; availabilityRules: AvailabilityRule[]; paymentRules: PaymentRule[] }) | null
> = async (args, context) => {
return context.entities.Venue.findFirst({
where: { id: args.venueId },
include: {
spaces: true,
availabilityRules: true,
paymentRules: true,
},
});
};export const getVenueById: GetVenueById<
GetVenueByIdPayload,
(Venue & { spaces: Space[]; availabilityRules: AvailabilityRule[]; paymentRules: PaymentRule[] }) | null
> = async (args, context) => {
return context.entities.Venue.findFirst({
where: { id: args.venueId },
include: {
spaces: true,
availabilityRules: true,
paymentRules: true,
},
});
}; Property 'paymentRules' is incompatible with index signature.
Type '{ id: string; venueId: string; spaceIds: string[]; priority: number; ruleType: RuleType; pricePerHour: Decimal | null; multiplier: Decimal | null; discountRate: Decimal | null; ... 8 more ...; updatedAt: Date; }[]' is not assignable to type 'SuperJSONValue'.
...
Property 'pricePerHour' is incompatible with index signature.
Type 'Decimal | null' is not assignable to type 'SuperJSONValue'.
Type 'Decimal' is not assignable to type 'SuperJSONValue'.
Type 'Decimal' is not assignable to type 'SuperJSONObject'.
Index signature for type 'string' is missing in type 'Decimal'.ts(2344) Property 'paymentRules' is incompatible with index signature.
Type '{ id: string; venueId: string; spaceIds: string[]; priority: number; ruleType: RuleType; pricePerHour: Decimal | null; multiplier: Decimal | null; discountRate: Decimal | null; ... 8 more ...; updatedAt: Date; }[]' is not assignable to type 'SuperJSONValue'.
...
Property 'pricePerHour' is incompatible with index signature.
Type 'Decimal | null' is not assignable to type 'SuperJSONValue'.
Type 'Decimal' is not assignable to type 'SuperJSONValue'.
Type 'Decimal' is not assignable to type 'SuperJSONObject'.
Index signature for type 'string' is missing in type 'Decimal'.ts(2344)How to resolve??