Static/reusable custom window functions

Hello, I'm trying to buld a properly typed array_agg window function and would like to reuse the existing FunctionModule in a reusable way, so to have orderby, over, and so on. Is there a way to get the function module you get from fn.agg outside of an expression builder and without creating a puppet kysely instance, so to create an array_agg function and return what fn.agg return but properly typed? As an example:
const array_agg = (expr: T) => sql.fn.agg<DeriveFrom<T>>('array_agg', [expr])
const array_agg = (expr: T) => sql.fn.agg<DeriveFrom<T>>('array_agg', [expr])
(right now there's no sql.fn forcing you to use a kysely instance or an expression builder to access the fn function module)
1 Reply
Kristian Notari
Kristian NotariOP10mo ago
Also, I noticed there's no way to accomplish the following if I'm right:
array_agg("c1" order by "c2" asc)
array_agg("c1" order by "c2" asc)
cause the orderBy bit is only available after applying a over partitioning. Is that correct?
Want results from more Discord servers?
Add your server