drizzle-team / drizzle-team/drizzle-orm
[FEATURE]: Add findFirstOrThrow() method
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Describe what you want
I've been integrating drizzle into my codebase (replacing Prisma) and so far I've had to write hundreds of snippets like this:
```ts
const feedTopic = await db.query.feedTopic.findFirst({
where: eq(schema.feedTopic.id, input.id)
})
if (!feedTopic) throw new Error('Feed topic not found')
return feedTopic
```
To save users from (mild) carpal tunnel I suggest simply adding a `findFirstOrThrow` method (like Prisma has)
The above becomes this:
```ts
return db.query.feedTopic.findFirstOrThrow({
where: eq(schema.feedTopic.id, input.id)
})
```
Bikeshedding, but it would be a nice little DX improvement.
Contributor guide
Assessment
This issue has not been assessed yet.