-
🎉 Added support for
HAVING
clause -
🎉 Added support for referencing selected fields in
.where()
,.having()
,.groupBy()
and.orderBy()
using an optional callback:await db .select({ id: citiesTable.id, name: sql<string>`upper(${citiesTable.name})`.as('upper_name'), usersCount: sql<number>`count(${users2Table.id})::int`.as('users_count'), }) .from(citiesTable) .leftJoin(users2Table, eq(users2Table.cityId, citiesTable.id)) .where(({ name }) => sql`length(${name}) >= 3`) .groupBy(citiesTable.id) .having(({ usersCount }) => sql`${usersCount} > 0`) .orderBy(({ name }) => name);