kysely 0.3.8 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,9 +44,11 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
44
44
  * Find a row by column value:
45
45
  *
46
46
  * ```ts
47
- * db.selectFrom('person')
48
- * .where('id', '=', 100)
47
+ * const person = await db
48
+ * .selectFrom('person')
49
49
  * .selectAll()
50
+ * .where('id', '=', 100)
51
+ * .executeTakeFirst()
50
52
  * ```
51
53
  *
52
54
  * The generated SQL (postgresql):
@@ -60,9 +62,11 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
60
62
  * you can always use `db.raw('your operator')`.
61
63
  *
62
64
  * ```ts
63
- * db.selectFrom('person')
64
- * .where('id', '>', 100)
65
+ * const persons = await db
66
+ * .selectFrom('person')
65
67
  * .selectAll()
68
+ * .where('id', '>', 100)
69
+ * .execute()
66
70
  * ```
67
71
  *
68
72
  * The generated SQL (postgresql):
@@ -72,22 +76,25 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
72
76
  * ```
73
77
  *
74
78
  * @example
75
- * A `where in` query an be built by using the `in` operator and an array
76
- * of values. The values in the array can also be subqueries or raw
77
- * instances.
79
+ * The `where` methods don't change the type of the query. You can add
80
+ * conditional `where`s easily by doing something like this:
78
81
  *
79
82
  * ```ts
80
- * db.selectFrom('person')
81
- * .where('person.id', 'in', [100, 200, 300])
83
+ * let query = db
84
+ * .selectFrom('person')
82
85
  * .selectAll()
83
- * ```
84
86
  *
85
- * The generated SQL (postgresql):
87
+ * if (firstName) {
88
+ * query = query.where('first_name', '=', firstName)
89
+ * }
86
90
  *
87
- * ```sql
88
- * select * from "person" where "id" in ($1, $2, $3)
91
+ * const persons = await query.execute()
89
92
  * ```
90
93
  *
94
+ * This is true for basically all methods execpt the `select` and
95
+ * `returning` methods, which DO change the return type of the
96
+ * query.
97
+ *
91
98
  * @example
92
99
  * Both the first and third argument can also be subqueries.
93
100
  * A subquery is defined by passing a function and calling
@@ -95,15 +102,18 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
95
102
  * function:
96
103
  *
97
104
  * ```ts
98
- * db.selectFrom('person')
105
+ * const persons = await db
106
+ * .selectFrom('person')
107
+ * .selectAll()
99
108
  * .where(
100
109
  * (qb) => qb.subQuery('pet')
101
- * .select('pet.id')
102
- * .whereRef('pet.owner_id', '=', 'person.id'),
103
- * 'in',
104
- * [100, 200, 300]
110
+ * .select('pet.name')
111
+ * .whereRef('pet.owner_id', '=', 'person.id')
112
+ * .limit(1),
113
+ * '=',
114
+ * 'Fluffy'
105
115
  * )
106
- * .selectAll()
116
+ * .execute()
107
117
  * ```
108
118
  *
109
119
  * The generated SQL (postgresql):
@@ -112,10 +122,30 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
112
122
  * select *
113
123
  * from "person"
114
124
  * where (
115
- * select "pet"."id"
125
+ * select "pet"."name"
116
126
  * from "pet"
117
127
  * where "pet"."owner_id" = "person"."id"
118
- * ) in ($1, $2, $3)
128
+ * limit $1
129
+ * ) = $2
130
+ * ```
131
+ *
132
+ * @example
133
+ * A `where in` query can be built by using the `in` operator and an array
134
+ * of values. The values in the array can also be subqueries or raw
135
+ * instances.
136
+ *
137
+ * ```ts
138
+ * const persons = await db
139
+ * .selectFrom('person')
140
+ * .selectAll()
141
+ * .where('person.id', 'in', [100, 200, 300])
142
+ * .execute()
143
+ * ```
144
+ *
145
+ * The generated SQL (postgresql):
146
+ *
147
+ * ```sql
148
+ * select * from "person" where "id" in ($1, $2, $3)
119
149
  * ```
120
150
  *
121
151
  * @example
@@ -123,20 +153,21 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
123
153
  * as any of the arguments, including the operator:
124
154
  *
125
155
  * ```ts
126
- * db.selectFrom('person')
156
+ * const persons = await db
157
+ * .selectFrom('person')
158
+ * .selectAll()
127
159
  * .where(
128
160
  * db.raw('coalesce(first_name, last_name)'),
129
161
  * 'like',
130
162
  * '%' + name + '%',
131
163
  * )
132
- * .selectAll()
164
+ * .execute()
133
165
  * ```
134
166
  *
135
167
  * The generated SQL (postgresql):
136
168
  *
137
169
  * ```sql
138
- * select *
139
- * from "person"
170
+ * select * from "person"
140
171
  * where coalesce(first_name, last_name) like $1
141
172
  * ```
142
173
  *
@@ -145,12 +176,14 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
145
176
  * used to create parentheses around other where clauses:
146
177
  *
147
178
  * ```ts
148
- * db.selectFrom('person')
179
+ * const persons = await db
180
+ * .selectFrom('person')
149
181
  * .selectAll()
150
182
  * .where((qb) => qb
151
183
  * .where('id', '=', 1)
152
184
  * .orWhere('id', '=', 2)
153
185
  * )
186
+ * .execute()
154
187
  * ```
155
188
  *
156
189
  * The generated SQL (postgresql):
@@ -174,10 +207,12 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
174
207
  * ```ts
175
208
  * const { ref } = db.dynamic
176
209
  *
177
- * db.selectFrom('person')
210
+ * const persons = await db
211
+ * .selectFrom('person')
178
212
  * .selectAll()
179
213
  * .where(ref(columnFromUserInput), '=', 1)
180
214
  * .orWhere(db.raw('??', [columnFromUserInput]), '=', 2)
215
+ * .execute()
181
216
  * ```
182
217
  */
183
218
  where<RE extends ReferenceExpression<DB, TB>>(lhs: RE, op: FilterOperator, rhs: ValueExpressionOrList<DB, TB, RE>): QueryBuilder<DB, TB, O>;
@@ -209,7 +244,8 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
209
244
  * Usage in a subquery:
210
245
  *
211
246
  * ```ts
212
- * db.selectFrom('person)
247
+ * const persons = await db
248
+ * .selectFrom('person')
213
249
  * .selectAll('person')
214
250
  * .select((qb) => qb
215
251
  * .subQuery('pet')
@@ -218,6 +254,7 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
218
254
  * .limit(1)
219
255
  * .as('pet_name')
220
256
  * )
257
+ * .execute()
221
258
  * ```
222
259
  *
223
260
  * The generated SQL (postgresql):
@@ -227,8 +264,9 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
227
264
  * select "name"
228
265
  * from "pet"
229
266
  * where "pet"."owner_id" = "person"."id"
230
- * ) as pet_name
231
- * from "person"`
267
+ * limit $1
268
+ * ) as "pet_name"
269
+ * from "person"
232
270
  */
233
271
  whereRef(lhs: ReferenceExpression<DB, TB>, op: FilterOperator, rhs: ReferenceExpression<DB, TB>): QueryBuilder<DB, TB, O>;
234
272
  /**
@@ -241,10 +279,12 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
241
279
  *
242
280
  * @example
243
281
  * ```ts
244
- * db.selectFrom('person')
282
+ * const persons = await db
283
+ * .selectFrom('person')
245
284
  * .selectAll()
246
285
  * .where('id', '=', 1)
247
286
  * .orWhere('id', '=', 2)
287
+ * .execute()
248
288
  * ```
249
289
  *
250
290
  * The generated SQL (postgresql):
@@ -257,12 +297,14 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
257
297
  * Grouping with parentheses:
258
298
  *
259
299
  * ```ts
260
- * db.selectFrom('person')
300
+ * const persons = await db
301
+ * .selectFrom('person')
261
302
  * .selectAll()
262
303
  * .where((qb) => qb
263
304
  * .where('id', '=', 1)
264
305
  * .orWhere('id', '=', 2)
265
306
  * )
307
+ * .execute()
266
308
  * ```
267
309
  *
268
310
  * The generated SQL (postgresql):
@@ -276,12 +318,14 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
276
318
  * if you are looping through a set of conditions:
277
319
  *
278
320
  * ```ts
279
- * db.selectFrom('person')
321
+ * const persons = await db
322
+ * .selectFrom('person')
280
323
  * .selectAll()
281
324
  * .where((qb) => qb
282
325
  * .orWhere('id', '=', 1)
283
326
  * .orWhere('id', '=', 2)
284
327
  * )
328
+ * .execute()
285
329
  * ```
286
330
  *
287
331
  * The generated SQL (postgresql):
@@ -308,7 +352,8 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
308
352
  * The query below selets all persons that own a pet named Catto:
309
353
  *
310
354
  * ```ts
311
- * db.selectFrom('person')
355
+ * const persons = await db
356
+ * .selectFrom('person')
312
357
  * .selectAll()
313
358
  * .whereExists((qb) => qb
314
359
  * .subQuery('pet')
@@ -316,6 +361,7 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
316
361
  * .whereRef('person.id', '=', 'pet.owner_id')
317
362
  * .where('pet.name', '=', 'Catto')
318
363
  * )
364
+ * .execute()
319
365
  * ```
320
366
  *
321
367
  * The generated SQL (postgresql):
@@ -414,14 +460,14 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
414
460
  /**
415
461
  * Adds a select clause to the query.
416
462
  *
417
- * When a column (or any expression) is selected, Kysely also adds it to the return
418
- * type of the query. Kysely is smart enough to parse the field names and types even
463
+ * When a column (or any expression) is selected, Kysely adds its type to the return
464
+ * type of the query. Kysely is smart enough to parse the column names and types even
419
465
  * from aliased columns, subqueries, raw expressions etc.
420
466
  *
421
467
  * Kysely only allows you to select columns and expressions that exist and would
422
468
  * produce valid SQL. However, Kysely is not perfect and there may be cases where
423
469
  * the type inference doesn't work and you need to override it. You can always
424
- * use the {@link Kysely.dynamic | dynamic} object and {@link Kysely.raw | raw}
470
+ * use the {@link Kysely.dynamic | dynamic} module and {@link Kysely.raw | raw}
425
471
  * to override the types.
426
472
  *
427
473
  * Select calls are additive. Calling `select('id').select('first_name')` is the
@@ -434,28 +480,29 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
434
480
  * Select a single column:
435
481
  *
436
482
  * ```ts
437
- * const [person] = await db.selectFrom('person')
483
+ * const persons = await db.selectFrom('person')
438
484
  * .select('id')
485
+ * .where('first_name', '=', 'Arnold')
439
486
  * .execute()
440
487
  *
441
- * person.id
488
+ * persons[0].id
442
489
  * ```
443
490
  *
444
491
  * The generated SQL (postgresql):
445
492
  *
446
493
  * ```sql
447
- * select "id" from "person"
494
+ * select "id" from "person" where "first_name" = $1
448
495
  * ```
449
496
  *
450
497
  * @example
451
498
  * Select a single column and specify a table:
452
499
  *
453
500
  * ```ts
454
- * const [person] = await db.selectFrom(['person', 'pet'])
501
+ * const persons = await db.selectFrom(['person', 'pet'])
455
502
  * .select('person.id')
456
503
  * .execute()
457
504
  *
458
- * person.id
505
+ * persons[0].id
459
506
  * ```
460
507
  *
461
508
  * The generated SQL (postgresql):
@@ -468,12 +515,12 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
468
515
  * Select multiple columns:
469
516
  *
470
517
  * ```ts
471
- * const [person] = await db.selectFrom('person')
518
+ * const persons = await db.selectFrom('person')
472
519
  * .select(['person.id', 'first_name'])
473
520
  * .execute()
474
521
  *
475
- * person.id
476
- * person.first_name
522
+ * persons[0].id
523
+ * persons[0].first_name
477
524
  * ```
478
525
  *
479
526
  * The generated SQL (postgresql):
@@ -483,18 +530,18 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
483
530
  * ```
484
531
  *
485
532
  * @example
486
- * Giving an alias for a selection:
533
+ * Aliased selections:
487
534
  *
488
535
  * ```ts
489
- * const [person] = await db.selectFrom('person')
536
+ * const persons = await db.selectFrom('person')
490
537
  * .select([
491
538
  * 'person.first_name as fn',
492
539
  * 'person.last_name as ln'
493
540
  * ])
494
541
  * .execute()
495
542
  *
496
- * person.fn
497
- * person.ln
543
+ * persons[0].fn
544
+ * persons[0].ln
498
545
  * ```
499
546
  *
500
547
  * The generated SQL (postgresql):
@@ -512,19 +559,20 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
512
559
  * method:
513
560
  *
514
561
  * ```ts
515
- * const [person] = await db.selectFrom('person')
562
+ * const persons = await db.selectFrom('person')
516
563
  * .select([
517
564
  * (qb) => qb
518
565
  * .subQuery('pet')
519
566
  * .whereRef('person.id', '=', 'pet.owner_id')
520
567
  * .select('pet.name')
568
+ * .limit(1)
521
569
  * .as('pet_name')
522
570
  * db.raw<string>("concat(first_name, ' ', last_name)").as('full_name')
523
571
  * ])
524
572
  * .execute()
525
573
  *
526
- * person.pet_name
527
- * person.full_name
574
+ * persons[0].pet_name
575
+ * persons[0].full_name
528
576
  * ```
529
577
  *
530
578
  * The generated SQL (postgresql):
@@ -535,7 +583,8 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
535
583
  * select "pet"."name"
536
584
  * from "pet"
537
585
  * where "person"."id" = "pet"."owner_id"
538
- * ) as pet_name,
586
+ * limit $1
587
+ * ) as "pet_name",
539
588
  * concat(first_name, ' ', last_name) as full_name
540
589
  * from "person"
541
590
  * ```
@@ -549,7 +598,7 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
549
598
  * the types) sometimes it's not possible or you just prefer to write more
550
599
  * dynamic code.
551
600
  * <br><br>
552
- * In this example, we use the `dynamic` object's methods to add selections
601
+ * In this example, we use the `dynamic` module's methods to add selections
553
602
  * dynamically:
554
603
  *
555
604
  * ```ts
@@ -562,7 +611,7 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
562
611
  * // You can use `keyof Person` if any column of an interface is allowed.
563
612
  * type PossibleColumns = 'last_name' | 'first_name' | 'birth_date'
564
613
  *
565
- * const [person] = await db.selectFrom('person')
614
+ * const spersons = await db.selectFrom('person')
566
615
  * .select([
567
616
  * ref<PossibleColumns>(columnFromUserInput)
568
617
  * 'id'
@@ -572,12 +621,12 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
572
621
  * // The resulting type contains all `PossibleColumns` as optional fields
573
622
  * // because we cannot know which field was actually selected before
574
623
  * // running the code.
575
- * const lastName: string | undefined = person.last_name
576
- * const firstName: string | undefined = person.first_name
577
- * const birthDate: string | undefined = person.birth_date
624
+ * const lastName: string | undefined = persons[0].last_name
625
+ * const firstName: string | undefined = persons[0].first_name
626
+ * const birthDate: string | undefined = persons[0].birth_date
578
627
  *
579
628
  * // The result type also contains the compile time selection `id`.
580
- * person.id
629
+ * persons[0].id
581
630
  * ```
582
631
  */
583
632
  select<S extends SelectExpression<DB, TB>>(selections: ReadonlyArray<S>): QueryBuilderWithSelection<DB, TB, O, S>;
@@ -585,6 +634,10 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
585
634
  /**
586
635
  * Adds `distinct on` selections to the select clause.
587
636
  *
637
+ * Takes the same inputs as the {@link QueryBuilder.select | select} method.
638
+ * See the {@link QueryBuilder.select | select} method's documentation for
639
+ * more examples.
640
+ *
588
641
  * @example
589
642
  * ```ts
590
643
  * await db.selectFrom('person')
@@ -653,7 +706,8 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
653
706
  *
654
707
  * @example
655
708
  * ```ts
656
- * await db.selectFrom('person')
709
+ * const persons = await db
710
+ * .selectFrom('person')
657
711
  * .selectAll()
658
712
  * .execute()
659
713
  * ```
@@ -666,7 +720,8 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
666
720
  *
667
721
  * @example
668
722
  * ```ts
669
- * await db.selectFrom('person')
723
+ * const persons = await db
724
+ * .selectFrom('person')
670
725
  * .selectAll('person')
671
726
  * .execute()
672
727
  * ```
@@ -679,7 +734,8 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
679
734
  *
680
735
  * @example
681
736
  * ```ts
682
- * await db.selectFrom(['person', 'pet'])
737
+ * const personsPets = await db
738
+ * .selectFrom(['person', 'pet'])
683
739
  * .selectAll(['person', 'pet'])
684
740
  * .execute()
685
741
  * ```
@@ -700,10 +756,17 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
700
756
  * Simple usage by providing a table name and two columns to join:
701
757
  *
702
758
  * ```ts
703
- * await db.selectFrom('person')
759
+ * const result = await db
760
+ * .selectFrom('person')
704
761
  * .selectAll()
705
762
  * .innerJoin('pet', 'pet.owner_id', 'person.id')
706
763
  * .execute()
764
+ *
765
+ * // The result has all `Person` columns
766
+ * result[0].first_name
767
+ *
768
+ * // The result has all `Pet` columns
769
+ * result[0].species
707
770
  * ```
708
771
  *
709
772
  * The generated SQL (postgresql):
@@ -794,7 +857,7 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
794
857
  * select "owner_id", "name"
795
858
  * from "pet"
796
859
  * where "name" = $1
797
- * ) as doggos
860
+ * ) as "doggos"
798
861
  * on "doggos"."owner_id" = "person"."id"
799
862
  * ```
800
863
  */
@@ -819,20 +882,24 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
819
882
  fullJoin<TE extends TableExpression<DB, TB>, K1 extends JoinReferenceExpression<DB, TB, TE>, K2 extends JoinReferenceExpression<DB, TB, TE>>(table: TE, k1: K1, k2: K2): QueryBuilderWithTable<DB, TB, O, TE>;
820
883
  fullJoin<TE extends TableExpression<DB, TB>, FN extends JoinCallbackExpression<DB, TB, TE>>(table: TE, callback: FN): QueryBuilderWithTable<DB, TB, O, TE>;
821
884
  /**
822
- * Sets the values to insert for an `insertInto` query.
885
+ * Sets the values to insert for an {@link Kysely.insertInto | insert} query.
823
886
  *
824
887
  * This method takes an object whose keys are column names and values are
825
- * values to insert. In addition to the column's type, the values can be `raw`
826
- * instances, select queries or the {@link Kysely.generated} placeholder.
888
+ * values to insert. In addition to the column's type, the values can be
889
+ * {@link Kysely.raw | raw} instances, select queries or the
890
+ * {@link Kysely.generated} placeholder.
827
891
  *
828
- * You must provide all values defined by the interface to for the table you
892
+ * You must provide all values defined by the interface for the table you
829
893
  * are inserting into. Values that are generated by the database like autoincrementing
830
- * identifiers can be marked with the {@link Kysely.generated} placeholder.
894
+ * identifiers can be marked with the {@link Kysely.generated} placeholder unless you
895
+ * want to insert a specific value instead of the generated default.
831
896
  *
832
897
  * The return value is the primary key of the inserted row BUT on some databases
833
898
  * there is no return value by default. That's the reason for the `number | undefined`
834
899
  * type of the return value. On postgres you need to additionally call `returning` to get
835
- * something out of the query.
900
+ * something out of the query. If you know your database engine always returns the primary
901
+ * key, you can use the {@link QueryBuilder.executeTakeFirstOrThrow | executeTakeFirstOrThrow}
902
+ * method to execute the query.
836
903
  *
837
904
  * @example
838
905
  * Insert a row into `person`:
@@ -844,7 +911,7 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
844
911
  * first_name: 'Jennifer',
845
912
  * last_name: 'Aniston'
846
913
  * })
847
- * .executeTakeFirst()
914
+ * .executeTakeFirstOrThrow()
848
915
  * ```
849
916
  *
850
917
  * The generated SQL (postgresql):
@@ -894,9 +961,9 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
894
961
  * last_name: 'Aniston'
895
962
  * })
896
963
  * .returning('id')
897
- * .executeTakeFirst()
964
+ * .executeTakeFirstOrThrow()
898
965
  *
899
- * row!.id
966
+ * row.id
900
967
  * ```
901
968
  *
902
969
  * The generated SQL (postgresql):
@@ -1016,7 +1083,7 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
1016
1083
  onConflictUpdate(column: AnyColumn<DB, TB>, updates: MutationObject<DB, TB>): QueryBuilder<DB, TB, O>;
1017
1084
  onConflictUpdate(columns: ReadonlyArray<AnyColumn<DB, TB>>, updates: MutationObject<DB, TB>): QueryBuilder<DB, TB, O>;
1018
1085
  /**
1019
- * Sets the values to update for an `updateTable` query.
1086
+ * Sets the values to update for an {@link Kysely.updateTable | update} query.
1020
1087
  *
1021
1088
  * This method takes an object whose keys are column names and values are
1022
1089
  * values to update. In addition to the column's type, the values can be `raw`
@@ -1047,7 +1114,7 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
1047
1114
  * ```
1048
1115
  *
1049
1116
  * @example
1050
- * On postgresql you need to chain `returning` to the query to get
1117
+ * On postgresql you ca chain `returning` to the query to get
1051
1118
  * the updated rows' columns (or any other expression) as the
1052
1119
  * return value:
1053
1120
  *
@@ -1060,7 +1127,7 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
1060
1127
  * })
1061
1128
  * .where('id', '=', 1)
1062
1129
  * .returning('id')
1063
- * .executeTakeFirst()
1130
+ * .executeTakeFirstOrThrow()
1064
1131
  *
1065
1132
  * row.id
1066
1133
  * ```
@@ -72,7 +72,8 @@ export class QueryBuilder {
72
72
  * Usage in a subquery:
73
73
  *
74
74
  * ```ts
75
- * db.selectFrom('person)
75
+ * const persons = await db
76
+ * .selectFrom('person')
76
77
  * .selectAll('person')
77
78
  * .select((qb) => qb
78
79
  * .subQuery('pet')
@@ -81,6 +82,7 @@ export class QueryBuilder {
81
82
  * .limit(1)
82
83
  * .as('pet_name')
83
84
  * )
85
+ * .execute()
84
86
  * ```
85
87
  *
86
88
  * The generated SQL (postgresql):
@@ -90,8 +92,9 @@ export class QueryBuilder {
90
92
  * select "name"
91
93
  * from "pet"
92
94
  * where "pet"."owner_id" = "person"."id"
93
- * ) as pet_name
94
- * from "person"`
95
+ * limit $1
96
+ * ) as "pet_name"
97
+ * from "person"
95
98
  */
96
99
  whereRef(lhs, op, rhs) {
97
100
  ensureCanHaveWhereClause(this.#queryNode);
@@ -129,7 +132,8 @@ export class QueryBuilder {
129
132
  * The query below selets all persons that own a pet named Catto:
130
133
  *
131
134
  * ```ts
132
- * db.selectFrom('person')
135
+ * const persons = await db
136
+ * .selectFrom('person')
133
137
  * .selectAll()
134
138
  * .whereExists((qb) => qb
135
139
  * .subQuery('pet')
@@ -137,6 +141,7 @@ export class QueryBuilder {
137
141
  * .whereRef('person.id', '=', 'pet.owner_id')
138
142
  * .where('pet.name', '=', 'Catto')
139
143
  * )
144
+ * .execute()
140
145
  * ```
141
146
  *
142
147
  * The generated SQL (postgresql):
@@ -449,7 +454,7 @@ export class QueryBuilder {
449
454
  });
450
455
  }
451
456
  /**
452
- * Sets the values to update for an `updateTable` query.
457
+ * Sets the values to update for an {@link Kysely.updateTable | update} query.
453
458
  *
454
459
  * This method takes an object whose keys are column names and values are
455
460
  * values to update. In addition to the column's type, the values can be `raw`
@@ -480,7 +485,7 @@ export class QueryBuilder {
480
485
  * ```
481
486
  *
482
487
  * @example
483
- * On postgresql you need to chain `returning` to the query to get
488
+ * On postgresql you ca chain `returning` to the query to get
484
489
  * the updated rows' columns (or any other expression) as the
485
490
  * return value:
486
491
  *
@@ -493,7 +498,7 @@ export class QueryBuilder {
493
498
  * })
494
499
  * .where('id', '=', 1)
495
500
  * .returning('id')
496
- * .executeTakeFirst()
501
+ * .executeTakeFirstOrThrow()
497
502
  *
498
503
  * row.id
499
504
  * ```