Type '{ vanVariation: { connect: { id: number; }; }; van: { connect: { id: number; }; };…
- User
Type '{ vanVariation: { connect: { id: number; }; }; van: { connect: { id: number; }; }; extras: { connect: { id: number; }[]; }; reference: string; user: { connectOrCreate: { where: { email: string; }; create: { email: string; name: string; phone: string; }; }; }; ... 4 more ...; cost?: number; }' is not assignable to type '(Without<BookingCreateInput, BookingUncheckedCreateInput> & BookingUncheckedCreateInput) | (Without<...> & BookingCreateInput)'. Type '{ vanVariation: { connect: { id: number; }; }; van: { connect: { id: number; }; }; extras: { connect: { id: number; }[]; }; reference: string; user: { connectOrCreate: { where: { email: string; }; create: { email: string; name: string; phone: string; }; }; }; ... 4 more ...; cost?: number; }' is not assignable to type 'Without<BookingUncheckedCreateInput, BookingCreateInput> & BookingCreateInput'. Type '{ vanVariation: { connect: { id: number; }; }; van: { connect: { id: number; }; }; extras: { connect: { id: number; }[]; }; reference: string; user: { connectOrCreate: { where: { email: string; }; create: { email: string; name: string; phone: string; }; }; }; ... 4 more ...; cost?: number; }' is not assignable to type 'BookingCreateInput'. Property 'cost' is optional in type '{ vanVariation: { connect: { id: number; }; }; van: { connect: { id: number; }; }; extras: { connect: { id: number; }[]; }; reference: string; user: { connectOrCreate: { where: { email: string; }; create: { email: string; name: string; phone: string; }; }; }; ... 4 more ...; cost?: number; }' but required in type 'BookingCreateInput'.ts(2322) index.d.ts(5216, 5): The expected type comes from property 'data' which is declared here on type '{ select?: BookingSelect; include?: BookingInclude; data: (Without<BookingCreateInput, BookingUncheckedCreateInput> & BookingUncheckedCreateInput) | (Without<...> & BookingCreateInput); }'
- Assistant
This error message is related to TypeScript's type system, and specifically to a type mismatch between an object you're trying to assign and a predefined type. The error message tells you that the object you're trying to assign has an optional property called
cost, while the predefined type expects this property to be required.To resolve this error, you can either make the
costproperty required in your object, or you can change the type definition to make it optional. It's up to you to decide which approach is more appropriate for your use case. If you're not sure, you can consult the documentation or ask a more experienced developer for advice. - User
I am using graphql and nestjs with prisma. I have a Van, VanVariation & Booking models. Each Van can have many VanVariations.
I want to do search based on fromDate & toDate. The search will return available vans for that date range, and then return all van variations for those vans that are available. It will then remove duplicates of the van variations so for example if there was 2 vans available both with a StarVan variation it would only return one StarVan variation with one of the two associated van Id's
- Assistant
To achieve this, you will need to perform some queries and filters on Prisma. Here's a high-level overview of the steps you can take: