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])

(right now there's no sql.fn forcing you to use a kysely instance or an expression builder to access the fn function module)
Was this page helpful?