I am currently using nest js with prisma as orm.
My problem occurs at the time of update , I have the following error the error is recurrent on all the entities which have a relationship with another. only in update.:
TS2322: Type 'UpdateMarketDto' is not assignable to type '(Without<MarketsUpdateInput, MarketsUncheckedUpdateInput> & MarketsUncheckedUpdateInput) | (Without<...> & MarketsUpdateInput)'. Type 'UpdateMarketDto' is not assignable to type 'Without<MarketsUncheckedUpdateInput, MarketsUpdateInput> & MarketsUpdateInput'. Types of property 'univer' are incompatible. Type 'CreateUniverDto | UpdateUniverDto' is not assignable to type 'UniversUpdateOneRequiredWithoutMarketsNestedInput'. Type 'CreateUniverDto' has no properties in common with type 'UniversUpdateOneRequiredWithoutMarketsNestedInput'.
This is the endpoint :
update(id: number, updateMarketDto: UpdateMarketDto) {
return this.prisma.markets.update({
where: { id },
data: updateMarketDto,
});
}
This is the createDTO :
export class CreateMarketDto {
@ApiProperty({ example: 'Femme' })
@IsString()
@IsDefined()
name: string;
@ApiProperty({ example: 'textile.png' })
@IsString()
@IsOptional()
icon: string;
@ApiProperty({ example: 'true' })
@IsBoolean()
isActive: boolean;
@ApiProperty({ example: '3' })
@IsOptional()
univer: CreateUniverDto | UpdateUniverDto;
}
This is the updateDTO :
export class UpdateMarketDto extends PartialType(CreateMarketDto) {}
This is prisma model :
model Univers {
id Int @id @default(autoincrement())
name String
icon String?
isActive Boolean @default(false)
markets Markets[]
}
model Markets {
id Int @id @default(autoincrement())
name String
icon String?
isActive Boolean @default(false)
univer Univers @relation(fields:[univerId], references: [id])
univerId Int
categories Categories[]
}