Return `null` by default if no record found

Hey, I am looking to have my queries return null instead of undefined if no records match my query when using executeTakeFirst. Is there a way to set this in the Kysely client?
Solution:
There's no way to do modify Kysely to return null in those cases.
Jump to solution
4 Replies
Solution
koskimas
koskimas10mo ago
There's no way to do modify Kysely to return null in those cases.
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
koskimas
koskimas10mo ago
const result = (await query.executeTakeFirst()) ?? null
const result = (await query.executeTakeFirst()) ?? null
bombillazo
bombillazo10mo ago
Yeah thats how we handle it but didnt want to sprinkle this all over the code in our queries or have to create a helper if it was avoidable.
Want results from more Discord servers?
Add your server