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
2 Replies
Hello @Rami kadaweh 👋
Is your goal to achieve this in a single prisma query?
You can check the number of records returned by the speciality query, and if no records are returned then you can query for language: 'en'
You can also create considering a client extension similar to this one:
https://github.com/prisma/prisma-client-extensions/tree/main/input-transformation
GitHub
prisma-client-extensions/input-transformation at main · prisma/pris...
Examples of Prisma Client extensions. Contribute to prisma/prisma-client-extensions development by creating an account on GitHub.