Emre
Emre
KKysely
Created by Emre on 10/19/2023 in #help
Type inference of queries with expressions in Webstorm
Webstorm reports that the type of const result = await selectable.select(({ eb }) => eb(eb.fn.count('id'), '>', 0).as('email_exists')).executeTakeFirst() is {email_exists: SqlBool} | undefined When I use result?.email_exists it complains that email_exists is undefined. And when I tell it to calculate the result's type explicitly it uses any. Yet when I manually enter the correct signature the error goes away. Is there problem with Webstorm's type inference with kysely or am I doing it wrong? I notice that there is no problem with simple queries such as select('id'), without an expression. https://github.com/esafak/kysely_query_results
11 replies
KKysely
Created by Emre on 10/19/2023 in #help
How to compose functions?
I have been unable to calculate select count(id) > 0 from foo. I tried this: .select(({ eb }) => { eb(eb.fn.count('id'), '>', 0) }) Where can I find examples for these things? I looked at https://kysely.dev/docs/examples/SELECT/function-calls
3 replies