*is this good idea? what are the other way to do?*...
# random
a
is this good idea? what are the other way to do?
Copy code
const enquiry = await db.enquiry.findFirst({
    where: { id },
    include: {
      users: {
        include: {
          user: true,
        },
      },
    },
  })

  if (!enquiry) throw new NotFoundError()

  const partner = enquiry.users.filter((arr) => arr.user.role === "PARTNER")[0]
  const customer = enquiry.users.filter((arr) => arr.user.role === "USER")[0]

return { ...enquiry, partner, customer }
j
Just a tip for error handling - you can make use of
rejectOnNotFound
which will automatically throw an error 👍 (so you won't need
if (!enquiry...
) It can be configured on a client level, or per request 🦜 https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#rejectonnotfound
🙌 1
a
yes I am using blitzjs😅 - https://blitzjs.com/