Replies: 1 comment 1 reply
-
Here is one way: type UserFindFirstInput = Parameters<typeof db['query']['users']['findFirst']>[0]
async function findFirstOrThrow(params: UserFindFirstInput) {
return await db.query.users.findFirst(params).then(val => {
if (!val) throw new Error("error")
return val
})
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to add a wrapper function
findFirstOrThrow
it has two issues:
how do I extend or make wrapper properly, to make it work on any tables and with correct typings?
Beta Was this translation helpful? Give feedback.
All reactions