diff --git a/src/expression/expression-builder.ts b/src/expression/expression-builder.ts index 5ff308322..3bb4e138e 100644 --- a/src/expression/expression-builder.ts +++ b/src/expression/expression-builder.ts @@ -71,7 +71,7 @@ export interface ExpressionBuilder { * eb.fn.count('pet.id').as('pet_count') * ]) * .groupBy('person.id') - * .having(count('pet.id'), '>', 10) + * .having((eb) => eb.fn.count('pet.id'), '>', 10) * .execute() * ``` * diff --git a/src/expression/expression-wrapper.ts b/src/expression/expression-wrapper.ts index e9818048b..98aeffd2c 100644 --- a/src/expression/expression-wrapper.ts +++ b/src/expression/expression-wrapper.ts @@ -25,7 +25,7 @@ export class ExpressionWrapper implements Expression { * ```ts * const result = await db * .selectFrom('person') - * .select(eb => + * .select((eb) => * eb.cmpr('first_name', '=', 'Jennifer').as('is_jennifer') * ) * .executeTakeFirstOrThrow() diff --git a/src/kysely.ts b/src/kysely.ts index 8b765b79b..f16755ddc 100644 --- a/src/kysely.ts +++ b/src/kysely.ts @@ -168,16 +168,14 @@ export class Kysely * calls. * * ```ts - * const { count } = db.fn - * * await db.selectFrom('person') * .innerJoin('pet', 'pet.owner_id', 'person.id') - * .select([ + * .select((eb) => [ * 'person.id', - * count('pet.id').as('pet_count') + * eb.fn.count('pet.id').as('pet_count') * ]) * .groupBy('person.id') - * .having(count('pet.id'), '>', 10) + * .having((eb) => eb.fn.count('pet.id'), '>', 10) * .execute() * ``` * diff --git a/src/query-builder/aggregate-function-builder.ts b/src/query-builder/aggregate-function-builder.ts index 51bb7aeb4..0cd494354 100644 --- a/src/query-builder/aggregate-function-builder.ts +++ b/src/query-builder/aggregate-function-builder.ts @@ -44,7 +44,7 @@ export class AggregateFunctionBuilder * const result = await db * .selectFrom('person') * .select( - * eb => eb.fn.count('id').as('person_count') + * (eb) => eb.fn.count('id').as('person_count') * ) * .executeTakeFirstOrThrow() * @@ -326,7 +326,7 @@ export class AggregateFunctionBuilder * const result = await db * .selectFrom('person') * .select( - * eb => eb.fn.avg('age').over().as('average_age') + * (eb) => eb.fn.avg('age').over().as('average_age') * ) * .execute() * ``` @@ -345,7 +345,7 @@ export class AggregateFunctionBuilder * const result = await db * .selectFrom('person') * .select( - * eb => eb.fn.avg('age').over( + * (eb) => eb.fn.avg('age').over( * ob => ob.partitionBy('last_name').orderBy('first_name', 'asc') * ).as('average_age') * ) diff --git a/src/query-builder/function-module.ts b/src/query-builder/function-module.ts index 84dd90092..0c865e972 100644 --- a/src/query-builder/function-module.ts +++ b/src/query-builder/function-module.ts @@ -138,10 +138,8 @@ export interface FunctionModule { * ### Examples * * ```ts - * const { avg } = db.fn - * * db.selectFrom('toy') - * .select(avg('price').as('avg_price')) + * .select((eb) => eb.fn.avg('price').as('avg_price')) * .execute() * ``` * @@ -170,10 +168,8 @@ export interface FunctionModule { * the first type argument: * * ```ts - * const { avg } = db.fn - * * db.selectFrom('toy') - * .select(avg('price').as('avg_price')) + * .select((eb) => eb.fn.avg('price').as('avg_price')) * .execute() * ``` * @@ -183,10 +179,8 @@ export interface FunctionModule { * function. * * ```ts - * const { avg } = db.fn - * * db.selectFrom('toy') - * .select(avg('price').as('avg_price')) + * .select((eb) => eb.fn.avg('price').as('avg_price')) * .execute() * ``` */ @@ -218,10 +212,8 @@ export interface FunctionModule { * ### Examples * * ```ts - * const { coalesce } = db.fn - * * db.selectFrom('participant') - * .select(coalesce('nickname', sql`''`).as('nickname')) + * .select((eb) => eb.fn.coalesce('nickname', sql`''`).as('nickname')) * .where('room_id', '=', roomId) * .execute() * ``` @@ -247,10 +239,8 @@ export interface FunctionModule { * You can combine this function with other helpers in this module: * * ```ts - * const { avg, coalesce } = db.fn - * * db.selectFrom('person') - * .select(coalesce(avg('age'), sql`0`).as('avg_age')) + * .select((eb) => eb.fn.coalesce(eb.fn.avg('age'), sql`0`).as('avg_age')) * .where('first_name', '=', 'Jennifer') * .execute() * ``` @@ -284,10 +274,8 @@ export interface FunctionModule { * ### Examples * * ```ts - * const { count } = db.fn - * * db.selectFrom('toy') - * .select(count('id').as('num_toys')) + * .select((eb) => eb.fn.count('id').as('num_toys')) * .execute() * ``` * @@ -308,10 +296,8 @@ export interface FunctionModule { * the type as the first type argument: * * ```ts - * const { count } = db.fn - * * db.selectFrom('toy') - * .select(count('id').as('num_toys')) + * .select((eb) => eb.fn.count('id').as('num_toys')) * .execute() * ``` * @@ -346,10 +332,8 @@ export interface FunctionModule { * ### Examples * * ```ts - * const { countAll } = db.fn - * * db.selectFrom('toy') - * .select(countAll().as('num_toys')) + * .select((eb) => eb.fn.countAll().as('num_toys')) * .execute() * ``` * @@ -370,10 +354,8 @@ export interface FunctionModule { * the type as the first type argument: * * ```ts - * const { countAll } = db.fn - * * db.selectFrom('toy') - * .select(countAll().as('num_toys')) + * .select((eb) => eb.fn.countAll().as('num_toys')) * .execute() * ``` * @@ -381,11 +363,9 @@ export interface FunctionModule { * table: * * ```ts - * const { countAll } = db.fn - * * db.selectFrom('toy') * .innerJoin('pet', 'pet.id', 'toy.pet_id') - * .select(countAll('toy').as('num_toys')) + * .select((eb) => eb.fn.countAll('toy').as('num_toys')) * .execute() * ``` * @@ -431,10 +411,8 @@ export interface FunctionModule { * ### Examples * * ```ts - * const { max } = db.fn - * * db.selectFrom('toy') - * .select(max('price').as('max_price')) + * .select((eb) => eb.fn.max('price').as('max_price')) * .execute() * ``` * @@ -458,10 +436,8 @@ export interface FunctionModule { * function. * * ```ts - * const { max } = db.fn - * * db.selectFrom('toy') - * .select(max('price').as('max_price')) + * .select((eb) => eb.fn.max('price').as('max_price')) * .execute() * ``` */ @@ -492,10 +468,8 @@ export interface FunctionModule { * ### Examples * * ```ts - * const { min } = db.fn - * * db.selectFrom('toy') - * .select(min('price').as('min_price')) + * .select((eb) => eb.fn.min('price').as('min_price')) * .execute() * ``` * @@ -519,10 +493,8 @@ export interface FunctionModule { * function. * * ```ts - * const { min } = db.fn - * * db.selectFrom('toy') - * .select(min('price').as('min_price')) + * .select((eb) => eb.fn.min('price').as('min_price')) * .execute() * ``` */ @@ -549,10 +521,8 @@ export interface FunctionModule { * ### Examples * * ```ts - * const { sum } = db.fn - * * db.selectFrom('toy') - * .select(sum('price').as('total_price')) + * .select((eb) => eb.fn.sum('price').as('total_price')) * .execute() * ``` * @@ -581,10 +551,8 @@ export interface FunctionModule { * the first type argument: * * ```ts - * const { sum } = db.fn - * * db.selectFrom('toy') - * .select(sum('price').as('total_price')) + * .select((eb) => eb.fn.sum('price').as('total_price')) * .execute() * ``` * @@ -594,10 +562,8 @@ export interface FunctionModule { * function. * * ```ts - * const { sum } = db.fn - * * db.selectFrom('toy') - * .select(sum('price').as('total_price')) + * .select((eb) => eb.fn.sum('price').as('total_price')) * .execute() * ``` */ diff --git a/src/query-builder/over-builder.ts b/src/query-builder/over-builder.ts index 91ada55d2..4c1d453db 100644 --- a/src/query-builder/over-builder.ts +++ b/src/query-builder/over-builder.ts @@ -30,7 +30,7 @@ export class OverBuilder * const result = await db * .selectFrom('person') * .select( - * eb => eb.fn.avg('age').over( + * (eb) => eb.fn.avg('age').over( * ob => ob.orderBy('first_name', 'asc').orderBy('last_name', 'asc') * ).as('average_age') * ) @@ -63,7 +63,7 @@ export class OverBuilder * const result = await db * .selectFrom('person') * .select( - * eb => eb.fn.avg('age').over( + * (eb) => eb.fn.avg('age').over( * ob => ob.partitionBy(['last_name', 'first_name']) * ).as('average_age') * ) diff --git a/src/query-builder/returning-interface.ts b/src/query-builder/returning-interface.ts index 8ba78fce8..d9d636287 100644 --- a/src/query-builder/returning-interface.ts +++ b/src/query-builder/returning-interface.ts @@ -54,7 +54,7 @@ export interface ReturningInterface { * first_name: 'Jennifer', * last_name: 'Aniston' * }) - * .returning(eb => [ + * .returning((eb) => [ * 'id as id', * sql`concat(first_name, ' ', last_name)`.as('full_name'), * eb.selectFrom('pets').select('pet.id').limit(1).as('first_pet_id') diff --git a/src/query-builder/select-query-builder.ts b/src/query-builder/select-query-builder.ts index dd07b4772..760657e09 100644 --- a/src/query-builder/select-query-builder.ts +++ b/src/query-builder/select-query-builder.ts @@ -1734,14 +1734,12 @@ export class SelectQueryBuilder * You can also call any other methods inside the callback: * * ```ts - * const { count } = db.fn - * * db.selectFrom('person') * .select('person.id') * .$if(filterByFirstName, (qb) => qb.where('first_name', '=', firstName)) * .$if(filterByPetCount, (qb) => qb * .innerJoin('pet', 'pet.owner_id', 'person.id') - * .having(count('pet.id'), '>', petCountLimit) + * .having((eb) => eb.fn.count('pet.id'), '>', petCountLimit) * .groupBy('person.id') * ) * ```