Flatten type of single column select?
Hi! I have helpers that look roughly like this:
the problem is that i cannot compose these helpers. in other words, i cannot do the following:
because the type of
orgOwnerId
does not match the type of the id
arg required by personName
any suggestions on how to solve this?
somehow "flattening" the return type of ownerId
to Expression<number>
would be ideal, if that's possible
and that 👆 should be valid, since ownerId
is a single-row single-column select? i thought about using $castTo
, but one concern is that $castTo
gives up type safety...Solution:Jump to solution
Hey 👋
There's a
$asScalar()
utility method that's probably landing in v0.28.
https://github.com/kysely-org/kysely/blob/v0.28/src/query-builder/select-query-builder.ts#L1938-L1986...2 Replies
Solution
Hey 👋
There's a
$asScalar()
utility method that's probably landing in v0.28.
https://github.com/kysely-org/kysely/blob/v0.28/src/query-builder/select-query-builder.ts#L1938-L1986nice thanks, i'll keep an eye out