Rami kadaweh
PPrisma
•Created by Rami kadaweh on 12/15/2024 in #help-and-questions
default data using prisma
const specialities = await this.prisma.speciality.findMany({
include: {
specialityLabel: { where: { language: 'fr'}}
}
})
i want if specific speciality does not have record specialityLabel with language 'fr' to let it got the record with language : 'en' as default
4 replies
PPrisma
•Created by Rami kadaweh on 12/11/2024 in #help-and-questions
hello guys , i have a quetion about sorting in relational field in prisma , i have the below models:
hello guys , i have a quetion about sorting in relational field in prisma , i have the below models:
model speciality {
id String @id @default(uuid())
medical_Files medical_File[]
medicalFileTemplate medical_File_templates[]
institutionUsers institutionUsers[]
created_at DateTime @default(now())
updated_at DateTime? @updatedAt
InstitutionExistingSpecialities InstitutionExistingSpecialities[]
InviteNewUsers InviteNewUsers[]
joinInstitutionRequests joinInstitutionRequests[]
collaborationSpeciality collaborationSpeciality[]
selectListSpeciality selectListSpeciality[]
specialityLabel specialityLabel[]
}
model expertiseLabel {
id String @id @default(uuid())
label String
language availableLanguages
expertise expertise @relation(fields: [expertiseId], references: [id], onDelete: Cascade)
expertiseId String
priority Int @default(0)
created_at DateTime @default(now())
updated_at DateTime? @updatedAt
@@unique([expertiseId, language])
}
and i have the below code in nest in order to fetch speciality and sort them by label : 'asc' of specialityLabel
const specialities = await this.prisma.speciality.findMany({
orderBy: { specialityLabel: { label: 'asc' } },
});
i got this error : error TS2353: Object literal may only specify known properties, and 'label' does not exist in type 'specialityLabelOrderByRelationAggregateInput'.
is there any solution that help me sort speciality by label of specialityLabel ?
5 replies