drizzle-orm
drizzle-orm copied to clipboard
[FEATURE]: Add findFirstOrThrow and findUniqueOrThrow to relational queries
Describe what you want
These methods are super helpful in Prisma to avoid boilerplate code when we want to fetch an entity that we know should exist, which is very often.
Prisma doc about it: https://www.prisma.io/docs/reference/api-reference/prisma-client-reference/#findfirstorthrow
One thing to note is the ability to throw a custom error per table/model: https://www.prisma.io/docs/reference/api-reference/prisma-client-reference/#throw-a-custom-error-per-model-and-operation-if-record-is-not-found This is great for raising domain errors instead of generic database errors.
I'm unsure where we would map the definition of custom errors in Drizzle, so suggestions are welcome!