Return first or throw

I have a hard time believing this hasn't been asked yet, but my search results have yet to yield anything. Is it not possible (or planned) to do something like:
const firstItem = db.select().from(users).where(eq(users.id, userId)).takeFirstOrThrow()
const firstItem = db.select().from(users).where(eq(users.id, userId)).takeFirstOrThrow()
2 Replies
McLean 25
McLean 25OP2y ago
The idea here being, that firstItems type will be User, and not User[] OK, finally found what I was looking for here: https://discord.com/channels/1043890932593987624/1085317796654764092
Dan
Dan2y ago
Not planned in the core library, but will probably be present in the convenience API layer on top.
Want results from more Discord servers?
Add your server