import { kysely } from "https://deno.land/x/kysely_postgrs_js_dialect@v0.27.4/deps.ts";
const { AggregateFunctionBuilder } = kysely;
Returns an aliased version of the function.
In addition to slapping as "the_alias"
to the end of the SQL,
this method also provides strict typing:
const result = await db
.selectFrom('person')
.select(
(eb) => eb.fn.count<number>('id').as('person_count')
)
.executeTakeFirstOrThrow()
// `person_count: number` field exists in the result type.
console.log(result.person_count)
The generated SQL (PostgreSQL):
select count("id") as "person_count"
from "person"
Parameters
alias: A
Returns
AliasedAggregateFunctionBuilder<DB, TB, O, A>