2
0

feat(db): 🗃️ Remove duplicate fields in PublicTypebot

This commit is contained in:
Baptiste Arnaud
2022-06-04 11:05:46 +02:00
parent 8ec117aee4
commit ad32ae02ef
11 changed files with 29 additions and 47 deletions

View File

@ -62,8 +62,9 @@ export const getServerSideProps: GetServerSideProps = async (
const getTypebotFromPublicId = async (publicId?: string) => {
if (!publicId) return null
const typebot = await prisma.publicTypebot.findUnique({
where: { publicId },
const typebot = await prisma.publicTypebot.findFirst({
where: { typebot: { publicId } },
include: { typebot: { select: { name: true } } },
})
if (isNotDefined(typebot)) return null
return omit(typebot as unknown as PublicTypebot, 'createdAt', 'updatedAt')
@ -71,7 +72,8 @@ const getTypebotFromPublicId = async (publicId?: string) => {
const getTypebotFromCustomDomain = async (customDomain: string) => {
const typebot = await prisma.publicTypebot.findFirst({
where: { customDomain },
where: { typebot: { customDomain } },
include: { typebot: { select: { name: true } } },
})
if (isNotDefined(typebot)) return null
return omit(typebot as unknown as PublicTypebot, 'createdAt', 'updatedAt')