would be nice to be able to use this for cases where we're loading an entity by an ID and we're like 99.9 percent sure it will be found and we don't want to clog up the code with extra typesafety checks for undefined every time
const result = await db.query.user.findUnique({
where: {
id: 42,
},
})
// => { id: 42, name: 'Chewbacca' } | undefined
const result = await db.query.user.findUniqueOrThrow({
where: {
id: 42,
},
})
// => { id: 42, name: 'Chewbacca' }
would be nice if the thrown error was something like: could not find user with id 1 rather than could not find user
would be nice to be able to use this for cases where we're loading an entity by an ID and we're like 99.9 percent sure it will be found and we don't want to clog up the code with extra typesafety checks for undefined every time
would be nice if the thrown error was something like:
could not find user with id 1rather thancould not find user