@supabase/postgrest-js 2.100.0-rc.0 → 2.100.1

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.
package/dist/index.mjs CHANGED
@@ -35,7 +35,19 @@ var PostgrestBuilder = class {
35
35
  *
36
36
  * @example
37
37
  * ```ts
38
- * import PostgrestQueryBuilder from '@supabase/postgrest-js'
38
+ * import { PostgrestQueryBuilder } from '@supabase/postgrest-js'
39
+ *
40
+ * const builder = new PostgrestQueryBuilder(
41
+ * new URL('https://xyzcompany.supabase.co/rest/v1/users'),
42
+ * { headers: new Headers({ apikey: 'public-anon-key' }) }
43
+ * )
44
+ * ```
45
+ *
46
+ * @category Database
47
+ *
48
+ * @example Creating a Postgrest query builder
49
+ * ```ts
50
+ * import { PostgrestQueryBuilder } from '@supabase/postgrest-js'
39
51
  *
40
52
  * const builder = new PostgrestQueryBuilder(
41
53
  * new URL('https://xyzcompany.supabase.co/rest/v1/users'),
@@ -63,6 +75,8 @@ var PostgrestBuilder = class {
63
75
  * throwing the error instead of returning it as part of a successful response.
64
76
  *
65
77
  * {@link https://github.com/supabase/supabase-js/issues/92}
78
+ *
79
+ * @category Database
66
80
  */
67
81
  throwOnError() {
68
82
  this.shouldThrowOnError = true;
@@ -70,12 +84,17 @@ var PostgrestBuilder = class {
70
84
  }
71
85
  /**
72
86
  * Set an HTTP header for the request.
87
+ *
88
+ * @category Database
73
89
  */
74
90
  setHeader(name, value) {
75
91
  this.headers = new Headers(this.headers);
76
92
  this.headers.set(name, value);
77
93
  return this;
78
94
  }
95
+ /** *
96
+ * @category Database
97
+ */
79
98
  then(onfulfilled, onrejected) {
80
99
  var _this = this;
81
100
  if (this.schema === void 0) {} else if (["GET", "HEAD"].includes(this.method)) this.headers.set("Accept-Profile", this.schema);
@@ -105,7 +124,7 @@ var PostgrestBuilder = class {
105
124
  const countHeader = (_this$headers$get2 = _this.headers.get("Prefer")) === null || _this$headers$get2 === void 0 ? void 0 : _this$headers$get2.match(/count=(exact|planned|estimated)/);
106
125
  const contentRange = (_res$headers$get = res$1.headers.get("content-range")) === null || _res$headers$get === void 0 ? void 0 : _res$headers$get.split("/");
107
126
  if (countHeader && contentRange && contentRange.length > 1) count = parseInt(contentRange[1]);
108
- if (_this.isMaybeSingle && _this.method === "GET" && Array.isArray(data)) if (data.length > 1) {
127
+ if (_this.isMaybeSingle && Array.isArray(data)) if (data.length > 1) {
109
128
  error = {
110
129
  code: "PGRST116",
111
130
  details: `Results contain ${data.length} rows, application/vnd.pgrst.object+json requires 1 row`,
@@ -119,7 +138,6 @@ var PostgrestBuilder = class {
119
138
  } else if (data.length === 1) data = data[0];
120
139
  else data = null;
121
140
  } else {
122
- var _error$details;
123
141
  const body = await res$1.text();
124
142
  try {
125
143
  error = JSON.parse(body);
@@ -135,11 +153,6 @@ var PostgrestBuilder = class {
135
153
  statusText = "No Content";
136
154
  } else error = { message: body };
137
155
  }
138
- if (error && _this.isMaybeSingle && (error === null || error === void 0 || (_error$details = error.details) === null || _error$details === void 0 ? void 0 : _error$details.includes("0 rows"))) {
139
- error = null;
140
- status = 200;
141
- statusText = "OK";
142
- }
143
156
  if (error && _this.shouldThrowOnError) throw new PostgrestError(error);
144
157
  }
145
158
  return {
@@ -198,6 +211,8 @@ var PostgrestBuilder = class {
198
211
  *
199
212
  * @typeParam NewResult - The new result type to override with
200
213
  * @deprecated Use overrideTypes<yourType, { merge: false }>() method at the end of your call chain instead
214
+ *
215
+ * @category Database
201
216
  */
202
217
  returns() {
203
218
  /* istanbul ignore next */
@@ -224,6 +239,77 @@ var PostgrestBuilder = class {
224
239
  * .overrideTypes<{ id: number; name: string }, { merge: false }>()
225
240
  * ```
226
241
  * @returns A PostgrestBuilder instance with the new type
242
+ *
243
+ * @category Database
244
+ *
245
+ * @example Complete Override type of successful response
246
+ * ```ts
247
+ * const { data } = await supabase
248
+ * .from('countries')
249
+ * .select()
250
+ * .overrideTypes<Array<MyType>, { merge: false }>()
251
+ * ```
252
+ *
253
+ * @exampleResponse Complete Override type of successful response
254
+ * ```ts
255
+ * let x: typeof data // MyType[]
256
+ * ```
257
+ *
258
+ * @example Complete Override type of object response
259
+ * ```ts
260
+ * const { data } = await supabase
261
+ * .from('countries')
262
+ * .select()
263
+ * .maybeSingle()
264
+ * .overrideTypes<MyType, { merge: false }>()
265
+ * ```
266
+ *
267
+ * @exampleResponse Complete Override type of object response
268
+ * ```ts
269
+ * let x: typeof data // MyType | null
270
+ * ```
271
+ *
272
+ * @example Partial Override type of successful response
273
+ * ```ts
274
+ * const { data } = await supabase
275
+ * .from('countries')
276
+ * .select()
277
+ * .overrideTypes<Array<{ status: "A" | "B" }>>()
278
+ * ```
279
+ *
280
+ * @exampleResponse Partial Override type of successful response
281
+ * ```ts
282
+ * let x: typeof data // Array<CountryRowProperties & { status: "A" | "B" }>
283
+ * ```
284
+ *
285
+ * @example Partial Override type of object response
286
+ * ```ts
287
+ * const { data } = await supabase
288
+ * .from('countries')
289
+ * .select()
290
+ * .maybeSingle()
291
+ * .overrideTypes<{ status: "A" | "B" }>()
292
+ * ```
293
+ *
294
+ * @exampleResponse Partial Override type of object response
295
+ * ```ts
296
+ * let x: typeof data // CountryRowProperties & { status: "A" | "B" } | null
297
+ * ```
298
+ *
299
+ * @example Example 5
300
+ * ```typescript
301
+ * // Merge with existing types (default behavior)
302
+ * const query = supabase
303
+ * .from('users')
304
+ * .select()
305
+ * .overrideTypes<{ custom_field: string }>()
306
+ *
307
+ * // Replace existing types completely
308
+ * const replaceQuery = supabase
309
+ * .from('users')
310
+ * .select()
311
+ * .overrideTypes<{ id: number; name: string }, { merge: false }>()
312
+ * ```
227
313
  */
228
314
  overrideTypes() {
229
315
  return this;
@@ -241,6 +327,41 @@ var PostgrestTransformBuilder = class extends PostgrestBuilder {
241
327
  * `data`.
242
328
  *
243
329
  * @param columns - The columns to retrieve, separated by commas
330
+ *
331
+ * @category Database
332
+ *
333
+ * @example With `upsert()`
334
+ * ```ts
335
+ * const { data, error } = await supabase
336
+ * .from('characters')
337
+ * .upsert({ id: 1, name: 'Han Solo' })
338
+ * .select()
339
+ * ```
340
+ *
341
+ * @exampleSql With `upsert()`
342
+ * ```sql
343
+ * create table
344
+ * characters (id int8 primary key, name text);
345
+ *
346
+ * insert into
347
+ * characters (id, name)
348
+ * values
349
+ * (1, 'Han');
350
+ * ```
351
+ *
352
+ * @exampleResponse With `upsert()`
353
+ * ```json
354
+ * {
355
+ * "data": [
356
+ * {
357
+ * "id": 1,
358
+ * "name": "Han Solo"
359
+ * }
360
+ * ],
361
+ * "status": 201,
362
+ * "statusText": "Created"
363
+ * }
364
+ * ```
244
365
  */
245
366
  select(columns) {
246
367
  let quoted = false;
@@ -270,6 +391,176 @@ var PostgrestTransformBuilder = class extends PostgrestBuilder {
270
391
  * its columns
271
392
  * @param options.foreignTable - Deprecated, use `options.referencedTable`
272
393
  * instead
394
+ *
395
+ * @category Database
396
+ *
397
+ * @example With `select()`
398
+ * ```ts
399
+ * const { data, error } = await supabase
400
+ * .from('characters')
401
+ * .select('id, name')
402
+ * .order('id', { ascending: false })
403
+ * ```
404
+ *
405
+ * @exampleSql With `select()`
406
+ * ```sql
407
+ * create table
408
+ * characters (id int8 primary key, name text);
409
+ *
410
+ * insert into
411
+ * characters (id, name)
412
+ * values
413
+ * (1, 'Luke'),
414
+ * (2, 'Leia'),
415
+ * (3, 'Han');
416
+ * ```
417
+ *
418
+ * @exampleResponse With `select()`
419
+ * ```json
420
+ * {
421
+ * "data": [
422
+ * {
423
+ * "id": 3,
424
+ * "name": "Han"
425
+ * },
426
+ * {
427
+ * "id": 2,
428
+ * "name": "Leia"
429
+ * },
430
+ * {
431
+ * "id": 1,
432
+ * "name": "Luke"
433
+ * }
434
+ * ],
435
+ * "status": 200,
436
+ * "statusText": "OK"
437
+ * }
438
+ * ```
439
+ *
440
+ * @exampleDescription On a referenced table
441
+ * Ordering with `referencedTable` doesn't affect the ordering of the
442
+ * parent table.
443
+ *
444
+ * @example On a referenced table
445
+ * ```ts
446
+ * const { data, error } = await supabase
447
+ * .from('orchestral_sections')
448
+ * .select(`
449
+ * name,
450
+ * instruments (
451
+ * name
452
+ * )
453
+ * `)
454
+ * .order('name', { referencedTable: 'instruments', ascending: false })
455
+ *
456
+ * ```
457
+ *
458
+ * @exampleSql On a referenced table
459
+ * ```sql
460
+ * create table
461
+ * orchestral_sections (id int8 primary key, name text);
462
+ * create table
463
+ * instruments (
464
+ * id int8 primary key,
465
+ * section_id int8 not null references orchestral_sections,
466
+ * name text
467
+ * );
468
+ *
469
+ * insert into
470
+ * orchestral_sections (id, name)
471
+ * values
472
+ * (1, 'strings'),
473
+ * (2, 'woodwinds');
474
+ * insert into
475
+ * instruments (id, section_id, name)
476
+ * values
477
+ * (1, 1, 'harp'),
478
+ * (2, 1, 'violin');
479
+ * ```
480
+ *
481
+ * @exampleResponse On a referenced table
482
+ * ```json
483
+ * {
484
+ * "data": [
485
+ * {
486
+ * "name": "strings",
487
+ * "instruments": [
488
+ * {
489
+ * "name": "violin"
490
+ * },
491
+ * {
492
+ * "name": "harp"
493
+ * }
494
+ * ]
495
+ * },
496
+ * {
497
+ * "name": "woodwinds",
498
+ * "instruments": []
499
+ * }
500
+ * ],
501
+ * "status": 200,
502
+ * "statusText": "OK"
503
+ * }
504
+ * ```
505
+ *
506
+ * @exampleDescription Order parent table by a referenced table
507
+ * Ordering with `referenced_table(col)` affects the ordering of the
508
+ * parent table.
509
+ *
510
+ * @example Order parent table by a referenced table
511
+ * ```ts
512
+ * const { data, error } = await supabase
513
+ * .from('instruments')
514
+ * .select(`
515
+ * name,
516
+ * section:orchestral_sections (
517
+ * name
518
+ * )
519
+ * `)
520
+ * .order('section(name)', { ascending: true })
521
+ *
522
+ * ```
523
+ *
524
+ * @exampleSql Order parent table by a referenced table
525
+ * ```sql
526
+ * create table
527
+ * orchestral_sections (id int8 primary key, name text);
528
+ * create table
529
+ * instruments (
530
+ * id int8 primary key,
531
+ * section_id int8 not null references orchestral_sections,
532
+ * name text
533
+ * );
534
+ *
535
+ * insert into
536
+ * orchestral_sections (id, name)
537
+ * values
538
+ * (1, 'strings'),
539
+ * (2, 'woodwinds');
540
+ * insert into
541
+ * instruments (id, section_id, name)
542
+ * values
543
+ * (1, 2, 'flute'),
544
+ * (2, 1, 'violin');
545
+ * ```
546
+ *
547
+ * @exampleResponse Order parent table by a referenced table
548
+ * ```json
549
+ * {
550
+ * "data": [
551
+ * {
552
+ * "name": "violin",
553
+ * "orchestral_sections": {"name": "strings"}
554
+ * },
555
+ * {
556
+ * "name": "flute",
557
+ * "orchestral_sections": {"name": "woodwinds"}
558
+ * }
559
+ * ],
560
+ * "status": 200,
561
+ * "statusText": "OK"
562
+ * }
563
+ * ```
273
564
  */
274
565
  order(column, { ascending = true, nullsFirst, foreignTable, referencedTable = foreignTable } = {}) {
275
566
  const key = referencedTable ? `${referencedTable}.order` : "order";
@@ -286,28 +577,156 @@ var PostgrestTransformBuilder = class extends PostgrestBuilder {
286
577
  * tables instead of the parent table
287
578
  * @param options.foreignTable - Deprecated, use `options.referencedTable`
288
579
  * instead
289
- */
290
- limit(count, { foreignTable, referencedTable = foreignTable } = {}) {
291
- const key = typeof referencedTable === "undefined" ? "limit" : `${referencedTable}.limit`;
292
- this.url.searchParams.set(key, `${count}`);
293
- return this;
294
- }
295
- /**
296
- * Limit the query result by starting at an offset `from` and ending at the offset `to`.
297
- * Only records within this range are returned.
298
- * This respects the query order and if there is no order clause the range could behave unexpectedly.
299
- * The `from` and `to` values are 0-based and inclusive: `range(1, 3)` will include the second, third
300
- * and fourth rows of the query.
301
580
  *
302
- * @param from - The starting index from which to limit the result
303
- * @param to - The last index to which to limit the result
304
- * @param options - Named parameters
305
- * @param options.referencedTable - Set this to limit rows of referenced
306
- * tables instead of the parent table
307
- * @param options.foreignTable - Deprecated, use `options.referencedTable`
308
- * instead
309
- */
310
- range(from, to, { foreignTable, referencedTable = foreignTable } = {}) {
581
+ * @category Database
582
+ *
583
+ * @example With `select()`
584
+ * ```ts
585
+ * const { data, error } = await supabase
586
+ * .from('characters')
587
+ * .select('name')
588
+ * .limit(1)
589
+ * ```
590
+ *
591
+ * @exampleSql With `select()`
592
+ * ```sql
593
+ * create table
594
+ * characters (id int8 primary key, name text);
595
+ *
596
+ * insert into
597
+ * characters (id, name)
598
+ * values
599
+ * (1, 'Luke'),
600
+ * (2, 'Leia'),
601
+ * (3, 'Han');
602
+ * ```
603
+ *
604
+ * @exampleResponse With `select()`
605
+ * ```json
606
+ * {
607
+ * "data": [
608
+ * {
609
+ * "name": "Luke"
610
+ * }
611
+ * ],
612
+ * "status": 200,
613
+ * "statusText": "OK"
614
+ * }
615
+ * ```
616
+ *
617
+ * @example On a referenced table
618
+ * ```ts
619
+ * const { data, error } = await supabase
620
+ * .from('orchestral_sections')
621
+ * .select(`
622
+ * name,
623
+ * instruments (
624
+ * name
625
+ * )
626
+ * `)
627
+ * .limit(1, { referencedTable: 'instruments' })
628
+ * ```
629
+ *
630
+ * @exampleSql On a referenced table
631
+ * ```sql
632
+ * create table
633
+ * orchestral_sections (id int8 primary key, name text);
634
+ * create table
635
+ * instruments (
636
+ * id int8 primary key,
637
+ * section_id int8 not null references orchestral_sections,
638
+ * name text
639
+ * );
640
+ *
641
+ * insert into
642
+ * orchestral_sections (id, name)
643
+ * values
644
+ * (1, 'strings');
645
+ * insert into
646
+ * instruments (id, section_id, name)
647
+ * values
648
+ * (1, 1, 'harp'),
649
+ * (2, 1, 'violin');
650
+ * ```
651
+ *
652
+ * @exampleResponse On a referenced table
653
+ * ```json
654
+ * {
655
+ * "data": [
656
+ * {
657
+ * "name": "strings",
658
+ * "instruments": [
659
+ * {
660
+ * "name": "violin"
661
+ * }
662
+ * ]
663
+ * }
664
+ * ],
665
+ * "status": 200,
666
+ * "statusText": "OK"
667
+ * }
668
+ * ```
669
+ */
670
+ limit(count, { foreignTable, referencedTable = foreignTable } = {}) {
671
+ const key = typeof referencedTable === "undefined" ? "limit" : `${referencedTable}.limit`;
672
+ this.url.searchParams.set(key, `${count}`);
673
+ return this;
674
+ }
675
+ /**
676
+ * Limit the query result by starting at an offset `from` and ending at the offset `to`.
677
+ * Only records within this range are returned.
678
+ * This respects the query order and if there is no order clause the range could behave unexpectedly.
679
+ * The `from` and `to` values are 0-based and inclusive: `range(1, 3)` will include the second, third
680
+ * and fourth rows of the query.
681
+ *
682
+ * @param from - The starting index from which to limit the result
683
+ * @param to - The last index to which to limit the result
684
+ * @param options - Named parameters
685
+ * @param options.referencedTable - Set this to limit rows of referenced
686
+ * tables instead of the parent table
687
+ * @param options.foreignTable - Deprecated, use `options.referencedTable`
688
+ * instead
689
+ *
690
+ * @category Database
691
+ *
692
+ * @example With `select()`
693
+ * ```ts
694
+ * const { data, error } = await supabase
695
+ * .from('characters')
696
+ * .select('name')
697
+ * .range(0, 1)
698
+ * ```
699
+ *
700
+ * @exampleSql With `select()`
701
+ * ```sql
702
+ * create table
703
+ * characters (id int8 primary key, name text);
704
+ *
705
+ * insert into
706
+ * characters (id, name)
707
+ * values
708
+ * (1, 'Luke'),
709
+ * (2, 'Leia'),
710
+ * (3, 'Han');
711
+ * ```
712
+ *
713
+ * @exampleResponse With `select()`
714
+ * ```json
715
+ * {
716
+ * "data": [
717
+ * {
718
+ * "name": "Luke"
719
+ * },
720
+ * {
721
+ * "name": "Leia"
722
+ * }
723
+ * ],
724
+ * "status": 200,
725
+ * "statusText": "OK"
726
+ * }
727
+ * ```
728
+ */
729
+ range(from, to, { foreignTable, referencedTable = foreignTable } = {}) {
311
730
  const keyOffset = typeof referencedTable === "undefined" ? "offset" : `${referencedTable}.offset`;
312
731
  const keyLimit = typeof referencedTable === "undefined" ? "limit" : `${referencedTable}.limit`;
313
732
  this.url.searchParams.set(keyOffset, `${from}`);
@@ -318,6 +737,66 @@ var PostgrestTransformBuilder = class extends PostgrestBuilder {
318
737
  * Set the AbortSignal for the fetch request.
319
738
  *
320
739
  * @param signal - The AbortSignal to use for the fetch request
740
+ *
741
+ * @category Database
742
+ *
743
+ * @remarks
744
+ * You can use this to set a timeout for the request.
745
+ *
746
+ * @exampleDescription Aborting requests in-flight
747
+ * You can use an [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) to abort requests.
748
+ * Note that `status` and `statusText` don't mean anything for aborted requests as the request wasn't fulfilled.
749
+ *
750
+ * @example Aborting requests in-flight
751
+ * ```ts
752
+ * const ac = new AbortController()
753
+ *
754
+ * const { data, error } = await supabase
755
+ * .from('very_big_table')
756
+ * .select()
757
+ * .abortSignal(ac.signal)
758
+ *
759
+ * // Abort the request after 100 ms
760
+ * setTimeout(() => ac.abort(), 100)
761
+ * ```
762
+ *
763
+ * @exampleResponse Aborting requests in-flight
764
+ * ```json
765
+ * {
766
+ * "error": {
767
+ * "message": "AbortError: The user aborted a request.",
768
+ * "details": "",
769
+ * "hint": "The request was aborted locally via the provided AbortSignal.",
770
+ * "code": ""
771
+ * },
772
+ * "status": 0,
773
+ * "statusText": ""
774
+ * }
775
+ *
776
+ * ```
777
+ *
778
+ * @example Set a timeout
779
+ * ```ts
780
+ * const { data, error } = await supabase
781
+ * .from('very_big_table')
782
+ * .select()
783
+ * .abortSignal(AbortSignal.timeout(1000 /* ms *\/))
784
+ * ```
785
+ *
786
+ * @exampleResponse Set a timeout
787
+ * ```json
788
+ * {
789
+ * "error": {
790
+ * "message": "FetchError: The user aborted a request.",
791
+ * "details": "",
792
+ * "hint": "",
793
+ * "code": ""
794
+ * },
795
+ * "status": 400,
796
+ * "statusText": "Bad Request"
797
+ * }
798
+ *
799
+ * ```
321
800
  */
322
801
  abortSignal(signal) {
323
802
  this.signal = signal;
@@ -328,6 +807,41 @@ var PostgrestTransformBuilder = class extends PostgrestBuilder {
328
807
  *
329
808
  * Query result must be one row (e.g. using `.limit(1)`), otherwise this
330
809
  * returns an error.
810
+ *
811
+ * @category Database
812
+ *
813
+ * @example With `select()`
814
+ * ```ts
815
+ * const { data, error } = await supabase
816
+ * .from('characters')
817
+ * .select('name')
818
+ * .limit(1)
819
+ * .single()
820
+ * ```
821
+ *
822
+ * @exampleSql With `select()`
823
+ * ```sql
824
+ * create table
825
+ * characters (id int8 primary key, name text);
826
+ *
827
+ * insert into
828
+ * characters (id, name)
829
+ * values
830
+ * (1, 'Luke'),
831
+ * (2, 'Leia'),
832
+ * (3, 'Han');
833
+ * ```
834
+ *
835
+ * @exampleResponse With `select()`
836
+ * ```json
837
+ * {
838
+ * "data": {
839
+ * "name": "Luke"
840
+ * },
841
+ * "status": 200,
842
+ * "statusText": "OK"
843
+ * }
844
+ * ```
331
845
  */
332
846
  single() {
333
847
  this.headers.set("Accept", "application/vnd.pgrst.object+json");
@@ -338,15 +852,80 @@ var PostgrestTransformBuilder = class extends PostgrestBuilder {
338
852
  *
339
853
  * Query result must be zero or one row (e.g. using `.limit(1)`), otherwise
340
854
  * this returns an error.
855
+ *
856
+ * @category Database
857
+ *
858
+ * @example With `select()`
859
+ * ```ts
860
+ * const { data, error } = await supabase
861
+ * .from('characters')
862
+ * .select()
863
+ * .eq('name', 'Katniss')
864
+ * .maybeSingle()
865
+ * ```
866
+ *
867
+ * @exampleSql With `select()`
868
+ * ```sql
869
+ * create table
870
+ * characters (id int8 primary key, name text);
871
+ *
872
+ * insert into
873
+ * characters (id, name)
874
+ * values
875
+ * (1, 'Luke'),
876
+ * (2, 'Leia'),
877
+ * (3, 'Han');
878
+ * ```
879
+ *
880
+ * @exampleResponse With `select()`
881
+ * ```json
882
+ * {
883
+ * "status": 200,
884
+ * "statusText": "OK"
885
+ * }
886
+ * ```
341
887
  */
342
888
  maybeSingle() {
343
- if (this.method === "GET") this.headers.set("Accept", "application/json");
344
- else this.headers.set("Accept", "application/vnd.pgrst.object+json");
345
889
  this.isMaybeSingle = true;
346
890
  return this;
347
891
  }
348
892
  /**
349
893
  * Return `data` as a string in CSV format.
894
+ *
895
+ * @category Database
896
+ *
897
+ * @exampleDescription Return data as CSV
898
+ * By default, the data is returned in JSON format, but can also be returned as Comma Separated Values.
899
+ *
900
+ * @example Return data as CSV
901
+ * ```ts
902
+ * const { data, error } = await supabase
903
+ * .from('characters')
904
+ * .select()
905
+ * .csv()
906
+ * ```
907
+ *
908
+ * @exampleSql Return data as CSV
909
+ * ```sql
910
+ * create table
911
+ * characters (id int8 primary key, name text);
912
+ *
913
+ * insert into
914
+ * characters (id, name)
915
+ * values
916
+ * (1, 'Luke'),
917
+ * (2, 'Leia'),
918
+ * (3, 'Han');
919
+ * ```
920
+ *
921
+ * @exampleResponse Return data as CSV
922
+ * ```json
923
+ * {
924
+ * "data": "id,name\n1,Luke\n2,Leia\n3,Han",
925
+ * "status": 200,
926
+ * "statusText": "OK"
927
+ * }
928
+ * ```
350
929
  */
351
930
  csv() {
352
931
  this.headers.set("Accept", "text/csv");
@@ -354,6 +933,8 @@ var PostgrestTransformBuilder = class extends PostgrestBuilder {
354
933
  }
355
934
  /**
356
935
  * Return `data` as an object in [GeoJSON](https://geojson.org) format.
936
+ *
937
+ * @category Database
357
938
  */
358
939
  geojson() {
359
940
  this.headers.set("Accept", "application/geo+json");
@@ -383,12 +964,82 @@ var PostgrestTransformBuilder = class extends PostgrestBuilder {
383
964
  *
384
965
  * @param options.format - The format of the output, can be `"text"` (default)
385
966
  * or `"json"`
386
- */
387
- explain({ analyze = false, verbose = false, settings = false, buffers = false, wal = false, format = "text" } = {}) {
388
- var _this$headers$get;
389
- const options = [
390
- analyze ? "analyze" : null,
391
- verbose ? "verbose" : null,
967
+ *
968
+ * @category Database
969
+ *
970
+ * @exampleDescription Get the execution plan
971
+ * By default, the data is returned in TEXT format, but can also be returned as JSON by using the `format` parameter.
972
+ *
973
+ * @example Get the execution plan
974
+ * ```ts
975
+ * const { data, error } = await supabase
976
+ * .from('characters')
977
+ * .select()
978
+ * .explain()
979
+ * ```
980
+ *
981
+ * @exampleSql Get the execution plan
982
+ * ```sql
983
+ * create table
984
+ * characters (id int8 primary key, name text);
985
+ *
986
+ * insert into
987
+ * characters (id, name)
988
+ * values
989
+ * (1, 'Luke'),
990
+ * (2, 'Leia'),
991
+ * (3, 'Han');
992
+ * ```
993
+ *
994
+ * @exampleResponse Get the execution plan
995
+ * ```js
996
+ * Aggregate (cost=33.34..33.36 rows=1 width=112)
997
+ * -> Limit (cost=0.00..18.33 rows=1000 width=40)
998
+ * -> Seq Scan on characters (cost=0.00..22.00 rows=1200 width=40)
999
+ * ```
1000
+ *
1001
+ * @exampleDescription Get the execution plan with analyze and verbose
1002
+ * By default, the data is returned in TEXT format, but can also be returned as JSON by using the `format` parameter.
1003
+ *
1004
+ * @example Get the execution plan with analyze and verbose
1005
+ * ```ts
1006
+ * const { data, error } = await supabase
1007
+ * .from('characters')
1008
+ * .select()
1009
+ * .explain({analyze:true,verbose:true})
1010
+ * ```
1011
+ *
1012
+ * @exampleSql Get the execution plan with analyze and verbose
1013
+ * ```sql
1014
+ * create table
1015
+ * characters (id int8 primary key, name text);
1016
+ *
1017
+ * insert into
1018
+ * characters (id, name)
1019
+ * values
1020
+ * (1, 'Luke'),
1021
+ * (2, 'Leia'),
1022
+ * (3, 'Han');
1023
+ * ```
1024
+ *
1025
+ * @exampleResponse Get the execution plan with analyze and verbose
1026
+ * ```js
1027
+ * Aggregate (cost=33.34..33.36 rows=1 width=112) (actual time=0.041..0.041 rows=1 loops=1)
1028
+ * Output: NULL::bigint, count(ROW(characters.id, characters.name)), COALESCE(json_agg(ROW(characters.id, characters.name)), '[]'::json), NULLIF(current_setting('response.headers'::text, true), ''::text), NULLIF(current_setting('response.status'::text, true), ''::text)
1029
+ * -> Limit (cost=0.00..18.33 rows=1000 width=40) (actual time=0.005..0.006 rows=3 loops=1)
1030
+ * Output: characters.id, characters.name
1031
+ * -> Seq Scan on public.characters (cost=0.00..22.00 rows=1200 width=40) (actual time=0.004..0.005 rows=3 loops=1)
1032
+ * Output: characters.id, characters.name
1033
+ * Query Identifier: -4730654291623321173
1034
+ * Planning Time: 0.407 ms
1035
+ * Execution Time: 0.119 ms
1036
+ * ```
1037
+ */
1038
+ explain({ analyze = false, verbose = false, settings = false, buffers = false, wal = false, format = "text" } = {}) {
1039
+ var _this$headers$get;
1040
+ const options = [
1041
+ analyze ? "analyze" : null,
1042
+ verbose ? "verbose" : null,
392
1043
  settings ? "settings" : null,
393
1044
  buffers ? "buffers" : null,
394
1045
  wal ? "wal" : null
@@ -402,6 +1053,8 @@ var PostgrestTransformBuilder = class extends PostgrestBuilder {
402
1053
  * Rollback the query.
403
1054
  *
404
1055
  * `data` will still be returned, but the query is not committed.
1056
+ *
1057
+ * @category Database
405
1058
  */
406
1059
  rollback() {
407
1060
  this.headers.append("Prefer", "tx=rollback");
@@ -412,6 +1065,38 @@ var PostgrestTransformBuilder = class extends PostgrestBuilder {
412
1065
  *
413
1066
  * @typeParam NewResult - The new result type to override with
414
1067
  * @deprecated Use overrideTypes<yourType, { merge: false }>() method at the end of your call chain instead
1068
+ *
1069
+ * @category Database
1070
+ *
1071
+ * @remarks
1072
+ * - Deprecated: use overrideTypes method instead
1073
+ *
1074
+ * @example Override type of successful response
1075
+ * ```ts
1076
+ * const { data } = await supabase
1077
+ * .from('countries')
1078
+ * .select()
1079
+ * .returns<Array<MyType>>()
1080
+ * ```
1081
+ *
1082
+ * @exampleResponse Override type of successful response
1083
+ * ```js
1084
+ * let x: typeof data // MyType[]
1085
+ * ```
1086
+ *
1087
+ * @example Override type of object response
1088
+ * ```ts
1089
+ * const { data } = await supabase
1090
+ * .from('countries')
1091
+ * .select()
1092
+ * .maybeSingle()
1093
+ * .returns<MyType>()
1094
+ * ```
1095
+ *
1096
+ * @exampleResponse Override type of object response
1097
+ * ```js
1098
+ * let x: typeof data // MyType | null
1099
+ * ```
415
1100
  */
416
1101
  returns() {
417
1102
  return this;
@@ -421,6 +1106,8 @@ var PostgrestTransformBuilder = class extends PostgrestBuilder {
421
1106
  * Only available in PostgREST v13+ and only works with PATCH and DELETE methods.
422
1107
  *
423
1108
  * @param value - The maximum number of rows that can be affected
1109
+ *
1110
+ * @category Database
424
1111
  */
425
1112
  maxAffected(value) {
426
1113
  this.headers.append("Prefer", "handling=strict");
@@ -440,6 +1127,43 @@ var PostgrestFilterBuilder = class extends PostgrestTransformBuilder {
440
1127
  *
441
1128
  * @param column - The column to filter on
442
1129
  * @param value - The value to filter with
1130
+ *
1131
+ * @category Database
1132
+ *
1133
+ * @example With `select()`
1134
+ * ```ts
1135
+ * const { data, error } = await supabase
1136
+ * .from('characters')
1137
+ * .select()
1138
+ * .eq('name', 'Leia')
1139
+ * ```
1140
+ *
1141
+ * @exampleSql With `select()`
1142
+ * ```sql
1143
+ * create table
1144
+ * characters (id int8 primary key, name text);
1145
+ *
1146
+ * insert into
1147
+ * characters (id, name)
1148
+ * values
1149
+ * (1, 'Luke'),
1150
+ * (2, 'Leia'),
1151
+ * (3, 'Han');
1152
+ * ```
1153
+ *
1154
+ * @exampleResponse With `select()`
1155
+ * ```json
1156
+ * {
1157
+ * "data": [
1158
+ * {
1159
+ * "id": 2,
1160
+ * "name": "Leia"
1161
+ * }
1162
+ * ],
1163
+ * "status": 200,
1164
+ * "statusText": "OK"
1165
+ * }
1166
+ * ```
443
1167
  */
444
1168
  eq(column, value) {
445
1169
  this.url.searchParams.append(column, `eq.${value}`);
@@ -450,6 +1174,47 @@ var PostgrestFilterBuilder = class extends PostgrestTransformBuilder {
450
1174
  *
451
1175
  * @param column - The column to filter on
452
1176
  * @param value - The value to filter with
1177
+ *
1178
+ * @category Database
1179
+ *
1180
+ * @example With `select()`
1181
+ * ```ts
1182
+ * const { data, error } = await supabase
1183
+ * .from('characters')
1184
+ * .select()
1185
+ * .neq('name', 'Leia')
1186
+ * ```
1187
+ *
1188
+ * @exampleSql With `select()`
1189
+ * ```sql
1190
+ * create table
1191
+ * characters (id int8 primary key, name text);
1192
+ *
1193
+ * insert into
1194
+ * characters (id, name)
1195
+ * values
1196
+ * (1, 'Luke'),
1197
+ * (2, 'Leia'),
1198
+ * (3, 'Han');
1199
+ * ```
1200
+ *
1201
+ * @exampleResponse With `select()`
1202
+ * ```json
1203
+ * {
1204
+ * "data": [
1205
+ * {
1206
+ * "id": 1,
1207
+ * "name": "Luke"
1208
+ * },
1209
+ * {
1210
+ * "id": 3,
1211
+ * "name": "Han"
1212
+ * }
1213
+ * ],
1214
+ * "status": 200,
1215
+ * "statusText": "OK"
1216
+ * }
1217
+ * ```
453
1218
  */
454
1219
  neq(column, value) {
455
1220
  this.url.searchParams.append(column, `neq.${value}`);
@@ -460,6 +1225,47 @@ var PostgrestFilterBuilder = class extends PostgrestTransformBuilder {
460
1225
  *
461
1226
  * @param column - The column to filter on
462
1227
  * @param value - The value to filter with
1228
+ *
1229
+ * @category Database
1230
+ *
1231
+ * @exampleDescription With `select()`
1232
+ * When using [reserved words](https://www.postgresql.org/docs/current/sql-keywords-appendix.html) for column names you need
1233
+ * to add double quotes e.g. `.gt('"order"', 2)`
1234
+ *
1235
+ * @example With `select()`
1236
+ * ```ts
1237
+ * const { data, error } = await supabase
1238
+ * .from('characters')
1239
+ * .select()
1240
+ * .gt('id', 2)
1241
+ * ```
1242
+ *
1243
+ * @exampleSql With `select()`
1244
+ * ```sql
1245
+ * create table
1246
+ * characters (id int8 primary key, name text);
1247
+ *
1248
+ * insert into
1249
+ * characters (id, name)
1250
+ * values
1251
+ * (1, 'Luke'),
1252
+ * (2, 'Leia'),
1253
+ * (3, 'Han');
1254
+ * ```
1255
+ *
1256
+ * @exampleResponse With `select()`
1257
+ * ```json
1258
+ * {
1259
+ * "data": [
1260
+ * {
1261
+ * "id": 3,
1262
+ * "name": "Han"
1263
+ * }
1264
+ * ],
1265
+ * "status": 200,
1266
+ * "statusText": "OK"
1267
+ * }
1268
+ * ```
463
1269
  */
464
1270
  gt(column, value) {
465
1271
  this.url.searchParams.append(column, `gt.${value}`);
@@ -470,6 +1276,47 @@ var PostgrestFilterBuilder = class extends PostgrestTransformBuilder {
470
1276
  *
471
1277
  * @param column - The column to filter on
472
1278
  * @param value - The value to filter with
1279
+ *
1280
+ * @category Database
1281
+ *
1282
+ * @example With `select()`
1283
+ * ```ts
1284
+ * const { data, error } = await supabase
1285
+ * .from('characters')
1286
+ * .select()
1287
+ * .gte('id', 2)
1288
+ * ```
1289
+ *
1290
+ * @exampleSql With `select()`
1291
+ * ```sql
1292
+ * create table
1293
+ * characters (id int8 primary key, name text);
1294
+ *
1295
+ * insert into
1296
+ * characters (id, name)
1297
+ * values
1298
+ * (1, 'Luke'),
1299
+ * (2, 'Leia'),
1300
+ * (3, 'Han');
1301
+ * ```
1302
+ *
1303
+ * @exampleResponse With `select()`
1304
+ * ```json
1305
+ * {
1306
+ * "data": [
1307
+ * {
1308
+ * "id": 2,
1309
+ * "name": "Leia"
1310
+ * },
1311
+ * {
1312
+ * "id": 3,
1313
+ * "name": "Han"
1314
+ * }
1315
+ * ],
1316
+ * "status": 200,
1317
+ * "statusText": "OK"
1318
+ * }
1319
+ * ```
473
1320
  */
474
1321
  gte(column, value) {
475
1322
  this.url.searchParams.append(column, `gte.${value}`);
@@ -480,6 +1327,43 @@ var PostgrestFilterBuilder = class extends PostgrestTransformBuilder {
480
1327
  *
481
1328
  * @param column - The column to filter on
482
1329
  * @param value - The value to filter with
1330
+ *
1331
+ * @category Database
1332
+ *
1333
+ * @example With `select()`
1334
+ * ```ts
1335
+ * const { data, error } = await supabase
1336
+ * .from('characters')
1337
+ * .select()
1338
+ * .lt('id', 2)
1339
+ * ```
1340
+ *
1341
+ * @exampleSql With `select()`
1342
+ * ```sql
1343
+ * create table
1344
+ * characters (id int8 primary key, name text);
1345
+ *
1346
+ * insert into
1347
+ * characters (id, name)
1348
+ * values
1349
+ * (1, 'Luke'),
1350
+ * (2, 'Leia'),
1351
+ * (3, 'Han');
1352
+ * ```
1353
+ *
1354
+ * @exampleResponse With `select()`
1355
+ * ```json
1356
+ * {
1357
+ * "data": [
1358
+ * {
1359
+ * "id": 1,
1360
+ * "name": "Luke"
1361
+ * }
1362
+ * ],
1363
+ * "status": 200,
1364
+ * "statusText": "OK"
1365
+ * }
1366
+ * ```
483
1367
  */
484
1368
  lt(column, value) {
485
1369
  this.url.searchParams.append(column, `lt.${value}`);
@@ -490,18 +1374,96 @@ var PostgrestFilterBuilder = class extends PostgrestTransformBuilder {
490
1374
  *
491
1375
  * @param column - The column to filter on
492
1376
  * @param value - The value to filter with
493
- */
494
- lte(column, value) {
495
- this.url.searchParams.append(column, `lte.${value}`);
496
- return this;
497
- }
498
- /**
499
- * Match only rows where `column` matches `pattern` case-sensitively.
500
1377
  *
501
- * @param column - The column to filter on
502
- * @param pattern - The pattern to match with
503
- */
504
- like(column, pattern) {
1378
+ * @category Database
1379
+ *
1380
+ * @example With `select()`
1381
+ * ```ts
1382
+ * const { data, error } = await supabase
1383
+ * .from('characters')
1384
+ * .select()
1385
+ * .lte('id', 2)
1386
+ * ```
1387
+ *
1388
+ * @exampleSql With `select()`
1389
+ * ```sql
1390
+ * create table
1391
+ * characters (id int8 primary key, name text);
1392
+ *
1393
+ * insert into
1394
+ * characters (id, name)
1395
+ * values
1396
+ * (1, 'Luke'),
1397
+ * (2, 'Leia'),
1398
+ * (3, 'Han');
1399
+ * ```
1400
+ *
1401
+ * @exampleResponse With `select()`
1402
+ * ```json
1403
+ * {
1404
+ * "data": [
1405
+ * {
1406
+ * "id": 1,
1407
+ * "name": "Luke"
1408
+ * },
1409
+ * {
1410
+ * "id": 2,
1411
+ * "name": "Leia"
1412
+ * }
1413
+ * ],
1414
+ * "status": 200,
1415
+ * "statusText": "OK"
1416
+ * }
1417
+ * ```
1418
+ */
1419
+ lte(column, value) {
1420
+ this.url.searchParams.append(column, `lte.${value}`);
1421
+ return this;
1422
+ }
1423
+ /**
1424
+ * Match only rows where `column` matches `pattern` case-sensitively.
1425
+ *
1426
+ * @param column - The column to filter on
1427
+ * @param pattern - The pattern to match with
1428
+ *
1429
+ * @category Database
1430
+ *
1431
+ * @example With `select()`
1432
+ * ```ts
1433
+ * const { data, error } = await supabase
1434
+ * .from('characters')
1435
+ * .select()
1436
+ * .like('name', '%Lu%')
1437
+ * ```
1438
+ *
1439
+ * @exampleSql With `select()`
1440
+ * ```sql
1441
+ * create table
1442
+ * characters (id int8 primary key, name text);
1443
+ *
1444
+ * insert into
1445
+ * characters (id, name)
1446
+ * values
1447
+ * (1, 'Luke'),
1448
+ * (2, 'Leia'),
1449
+ * (3, 'Han');
1450
+ * ```
1451
+ *
1452
+ * @exampleResponse With `select()`
1453
+ * ```json
1454
+ * {
1455
+ * "data": [
1456
+ * {
1457
+ * "id": 1,
1458
+ * "name": "Luke"
1459
+ * }
1460
+ * ],
1461
+ * "status": 200,
1462
+ * "statusText": "OK"
1463
+ * }
1464
+ * ```
1465
+ */
1466
+ like(column, pattern) {
505
1467
  this.url.searchParams.append(column, `like.${pattern}`);
506
1468
  return this;
507
1469
  }
@@ -510,6 +1472,8 @@ var PostgrestFilterBuilder = class extends PostgrestTransformBuilder {
510
1472
  *
511
1473
  * @param column - The column to filter on
512
1474
  * @param patterns - The patterns to match with
1475
+ *
1476
+ * @category Database
513
1477
  */
514
1478
  likeAllOf(column, patterns) {
515
1479
  this.url.searchParams.append(column, `like(all).{${patterns.join(",")}}`);
@@ -520,6 +1484,8 @@ var PostgrestFilterBuilder = class extends PostgrestTransformBuilder {
520
1484
  *
521
1485
  * @param column - The column to filter on
522
1486
  * @param patterns - The patterns to match with
1487
+ *
1488
+ * @category Database
523
1489
  */
524
1490
  likeAnyOf(column, patterns) {
525
1491
  this.url.searchParams.append(column, `like(any).{${patterns.join(",")}}`);
@@ -530,6 +1496,43 @@ var PostgrestFilterBuilder = class extends PostgrestTransformBuilder {
530
1496
  *
531
1497
  * @param column - The column to filter on
532
1498
  * @param pattern - The pattern to match with
1499
+ *
1500
+ * @category Database
1501
+ *
1502
+ * @example With `select()`
1503
+ * ```ts
1504
+ * const { data, error } = await supabase
1505
+ * .from('characters')
1506
+ * .select()
1507
+ * .ilike('name', '%lu%')
1508
+ * ```
1509
+ *
1510
+ * @exampleSql With `select()`
1511
+ * ```sql
1512
+ * create table
1513
+ * characters (id int8 primary key, name text);
1514
+ *
1515
+ * insert into
1516
+ * characters (id, name)
1517
+ * values
1518
+ * (1, 'Luke'),
1519
+ * (2, 'Leia'),
1520
+ * (3, 'Han');
1521
+ * ```
1522
+ *
1523
+ * @exampleResponse With `select()`
1524
+ * ```json
1525
+ * {
1526
+ * "data": [
1527
+ * {
1528
+ * "id": 1,
1529
+ * "name": "Luke"
1530
+ * }
1531
+ * ],
1532
+ * "status": 200,
1533
+ * "statusText": "OK"
1534
+ * }
1535
+ * ```
533
1536
  */
534
1537
  ilike(column, pattern) {
535
1538
  this.url.searchParams.append(column, `ilike.${pattern}`);
@@ -540,6 +1543,8 @@ var PostgrestFilterBuilder = class extends PostgrestTransformBuilder {
540
1543
  *
541
1544
  * @param column - The column to filter on
542
1545
  * @param patterns - The patterns to match with
1546
+ *
1547
+ * @category Database
543
1548
  */
544
1549
  ilikeAllOf(column, patterns) {
545
1550
  this.url.searchParams.append(column, `ilike(all).{${patterns.join(",")}}`);
@@ -550,6 +1555,8 @@ var PostgrestFilterBuilder = class extends PostgrestTransformBuilder {
550
1555
  *
551
1556
  * @param column - The column to filter on
552
1557
  * @param patterns - The patterns to match with
1558
+ *
1559
+ * @category Database
553
1560
  */
554
1561
  ilikeAnyOf(column, patterns) {
555
1562
  this.url.searchParams.append(column, `ilike(any).{${patterns.join(",")}}`);
@@ -588,6 +1595,47 @@ var PostgrestFilterBuilder = class extends PostgrestTransformBuilder {
588
1595
  *
589
1596
  * @param column - The column to filter on
590
1597
  * @param value - The value to filter with
1598
+ *
1599
+ * @category Database
1600
+ *
1601
+ * @exampleDescription Checking for nullness, true or false
1602
+ * Using the `eq()` filter doesn't work when filtering for `null`.
1603
+ *
1604
+ * Instead, you need to use `is()`.
1605
+ *
1606
+ * @example Checking for nullness, true or false
1607
+ * ```ts
1608
+ * const { data, error } = await supabase
1609
+ * .from('countries')
1610
+ * .select()
1611
+ * .is('name', null)
1612
+ * ```
1613
+ *
1614
+ * @exampleSql Checking for nullness, true or false
1615
+ * ```sql
1616
+ * create table
1617
+ * countries (id int8 primary key, name text);
1618
+ *
1619
+ * insert into
1620
+ * countries (id, name)
1621
+ * values
1622
+ * (1, 'null'),
1623
+ * (2, null);
1624
+ * ```
1625
+ *
1626
+ * @exampleResponse Checking for nullness, true or false
1627
+ * ```json
1628
+ * {
1629
+ * "data": [
1630
+ * {
1631
+ * "id": 2,
1632
+ * "name": "null"
1633
+ * }
1634
+ * ],
1635
+ * "status": 200,
1636
+ * "statusText": "OK"
1637
+ * }
1638
+ * ```
591
1639
  */
592
1640
  is(column, value) {
593
1641
  this.url.searchParams.append(column, `is.${value}`);
@@ -612,6 +1660,47 @@ var PostgrestFilterBuilder = class extends PostgrestTransformBuilder {
612
1660
  *
613
1661
  * @param column - The column to filter on
614
1662
  * @param values - The values array to filter with
1663
+ *
1664
+ * @category Database
1665
+ *
1666
+ * @example With `select()`
1667
+ * ```ts
1668
+ * const { data, error } = await supabase
1669
+ * .from('characters')
1670
+ * .select()
1671
+ * .in('name', ['Leia', 'Han'])
1672
+ * ```
1673
+ *
1674
+ * @exampleSql With `select()`
1675
+ * ```sql
1676
+ * create table
1677
+ * characters (id int8 primary key, name text);
1678
+ *
1679
+ * insert into
1680
+ * characters (id, name)
1681
+ * values
1682
+ * (1, 'Luke'),
1683
+ * (2, 'Leia'),
1684
+ * (3, 'Han');
1685
+ * ```
1686
+ *
1687
+ * @exampleResponse With `select()`
1688
+ * ```json
1689
+ * {
1690
+ * "data": [
1691
+ * {
1692
+ * "id": 2,
1693
+ * "name": "Leia"
1694
+ * },
1695
+ * {
1696
+ * "id": 3,
1697
+ * "name": "Han"
1698
+ * }
1699
+ * ],
1700
+ * "status": 200,
1701
+ * "statusText": "OK"
1702
+ * }
1703
+ * ```
615
1704
  */
616
1705
  in(column, values) {
617
1706
  const cleanedValues = Array.from(new Set(values)).map((s) => {
@@ -641,72 +1730,506 @@ var PostgrestFilterBuilder = class extends PostgrestTransformBuilder {
641
1730
  *
642
1731
  * @param column - The jsonb, array, or range column to filter on
643
1732
  * @param value - The jsonb, array, or range value to filter with
644
- */
645
- contains(column, value) {
646
- if (typeof value === "string") this.url.searchParams.append(column, `cs.${value}`);
647
- else if (Array.isArray(value)) this.url.searchParams.append(column, `cs.{${value.join(",")}}`);
648
- else this.url.searchParams.append(column, `cs.${JSON.stringify(value)}`);
649
- return this;
650
- }
651
- /**
652
- * Only relevant for jsonb, array, and range columns. Match only rows where
653
- * every element appearing in `column` is contained by `value`.
654
1733
  *
655
- * @param column - The jsonb, array, or range column to filter on
656
- * @param value - The jsonb, array, or range value to filter with
657
- */
658
- containedBy(column, value) {
659
- if (typeof value === "string") this.url.searchParams.append(column, `cd.${value}`);
660
- else if (Array.isArray(value)) this.url.searchParams.append(column, `cd.{${value.join(",")}}`);
661
- else this.url.searchParams.append(column, `cd.${JSON.stringify(value)}`);
662
- return this;
663
- }
664
- /**
665
- * Only relevant for range columns. Match only rows where every element in
666
- * `column` is greater than any element in `range`.
1734
+ * @category Database
667
1735
  *
668
- * @param column - The range column to filter on
669
- * @param range - The range to filter with
670
- */
671
- rangeGt(column, range) {
672
- this.url.searchParams.append(column, `sr.${range}`);
673
- return this;
674
- }
675
- /**
676
- * Only relevant for range columns. Match only rows where every element in
677
- * `column` is either contained in `range` or greater than any element in
678
- * `range`.
1736
+ * @example On array columns
1737
+ * ```ts
1738
+ * const { data, error } = await supabase
1739
+ * .from('issues')
1740
+ * .select()
1741
+ * .contains('tags', ['is:open', 'priority:low'])
1742
+ * ```
679
1743
  *
680
- * @param column - The range column to filter on
681
- * @param range - The range to filter with
682
- */
683
- rangeGte(column, range) {
684
- this.url.searchParams.append(column, `nxl.${range}`);
685
- return this;
686
- }
687
- /**
688
- * Only relevant for range columns. Match only rows where every element in
689
- * `column` is less than any element in `range`.
1744
+ * @exampleSql On array columns
1745
+ * ```sql
1746
+ * create table
1747
+ * issues (
1748
+ * id int8 primary key,
1749
+ * title text,
1750
+ * tags text[]
1751
+ * );
690
1752
  *
691
- * @param column - The range column to filter on
692
- * @param range - The range to filter with
693
- */
694
- rangeLt(column, range) {
695
- this.url.searchParams.append(column, `sl.${range}`);
696
- return this;
697
- }
698
- /**
699
- * Only relevant for range columns. Match only rows where every element in
700
- * `column` is either contained in `range` or less than any element in
701
- * `range`.
1753
+ * insert into
1754
+ * issues (id, title, tags)
1755
+ * values
1756
+ * (1, 'Cache invalidation is not working', array['is:open', 'severity:high', 'priority:low']),
1757
+ * (2, 'Use better names', array['is:open', 'severity:low', 'priority:medium']);
1758
+ * ```
702
1759
  *
703
- * @param column - The range column to filter on
704
- * @param range - The range to filter with
705
- */
706
- rangeLte(column, range) {
707
- this.url.searchParams.append(column, `nxr.${range}`);
708
- return this;
709
- }
1760
+ * @exampleResponse On array columns
1761
+ * ```json
1762
+ * {
1763
+ * "data": [
1764
+ * {
1765
+ * "title": "Cache invalidation is not working"
1766
+ * }
1767
+ * ],
1768
+ * "status": 200,
1769
+ * "statusText": "OK"
1770
+ * }
1771
+ * ```
1772
+ *
1773
+ * @exampleDescription On range columns
1774
+ * Postgres supports a number of [range
1775
+ * types](https://www.postgresql.org/docs/current/rangetypes.html). You
1776
+ * can filter on range columns using the string representation of range
1777
+ * values.
1778
+ *
1779
+ * @example On range columns
1780
+ * ```ts
1781
+ * const { data, error } = await supabase
1782
+ * .from('reservations')
1783
+ * .select()
1784
+ * .contains('during', '[2000-01-01 13:00, 2000-01-01 13:30)')
1785
+ * ```
1786
+ *
1787
+ * @exampleSql On range columns
1788
+ * ```sql
1789
+ * create table
1790
+ * reservations (
1791
+ * id int8 primary key,
1792
+ * room_name text,
1793
+ * during tsrange
1794
+ * );
1795
+ *
1796
+ * insert into
1797
+ * reservations (id, room_name, during)
1798
+ * values
1799
+ * (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
1800
+ * (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
1801
+ * ```
1802
+ *
1803
+ * @exampleResponse On range columns
1804
+ * ```json
1805
+ * {
1806
+ * "data": [
1807
+ * {
1808
+ * "id": 1,
1809
+ * "room_name": "Emerald",
1810
+ * "during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
1811
+ * }
1812
+ * ],
1813
+ * "status": 200,
1814
+ * "statusText": "OK"
1815
+ * }
1816
+ * ```
1817
+ *
1818
+ * @example On `jsonb` columns
1819
+ * ```ts
1820
+ * const { data, error } = await supabase
1821
+ * .from('users')
1822
+ * .select('name')
1823
+ * .contains('address', { postcode: 90210 })
1824
+ * ```
1825
+ *
1826
+ * @exampleSql On `jsonb` columns
1827
+ * ```sql
1828
+ * create table
1829
+ * users (
1830
+ * id int8 primary key,
1831
+ * name text,
1832
+ * address jsonb
1833
+ * );
1834
+ *
1835
+ * insert into
1836
+ * users (id, name, address)
1837
+ * values
1838
+ * (1, 'Michael', '{ "postcode": 90210, "street": "Melrose Place" }'),
1839
+ * (2, 'Jane', '{}');
1840
+ * ```
1841
+ *
1842
+ * @exampleResponse On `jsonb` columns
1843
+ * ```json
1844
+ * {
1845
+ * "data": [
1846
+ * {
1847
+ * "name": "Michael"
1848
+ * }
1849
+ * ],
1850
+ * "status": 200,
1851
+ * "statusText": "OK"
1852
+ * }
1853
+ * ```
1854
+ */
1855
+ contains(column, value) {
1856
+ if (typeof value === "string") this.url.searchParams.append(column, `cs.${value}`);
1857
+ else if (Array.isArray(value)) this.url.searchParams.append(column, `cs.{${value.join(",")}}`);
1858
+ else this.url.searchParams.append(column, `cs.${JSON.stringify(value)}`);
1859
+ return this;
1860
+ }
1861
+ /**
1862
+ * Only relevant for jsonb, array, and range columns. Match only rows where
1863
+ * every element appearing in `column` is contained by `value`.
1864
+ *
1865
+ * @param column - The jsonb, array, or range column to filter on
1866
+ * @param value - The jsonb, array, or range value to filter with
1867
+ *
1868
+ * @category Database
1869
+ *
1870
+ * @example On array columns
1871
+ * ```ts
1872
+ * const { data, error } = await supabase
1873
+ * .from('classes')
1874
+ * .select('name')
1875
+ * .containedBy('days', ['monday', 'tuesday', 'wednesday', 'friday'])
1876
+ * ```
1877
+ *
1878
+ * @exampleSql On array columns
1879
+ * ```sql
1880
+ * create table
1881
+ * classes (
1882
+ * id int8 primary key,
1883
+ * name text,
1884
+ * days text[]
1885
+ * );
1886
+ *
1887
+ * insert into
1888
+ * classes (id, name, days)
1889
+ * values
1890
+ * (1, 'Chemistry', array['monday', 'friday']),
1891
+ * (2, 'History', array['monday', 'wednesday', 'thursday']);
1892
+ * ```
1893
+ *
1894
+ * @exampleResponse On array columns
1895
+ * ```json
1896
+ * {
1897
+ * "data": [
1898
+ * {
1899
+ * "name": "Chemistry"
1900
+ * }
1901
+ * ],
1902
+ * "status": 200,
1903
+ * "statusText": "OK"
1904
+ * }
1905
+ * ```
1906
+ *
1907
+ * @exampleDescription On range columns
1908
+ * Postgres supports a number of [range
1909
+ * types](https://www.postgresql.org/docs/current/rangetypes.html). You
1910
+ * can filter on range columns using the string representation of range
1911
+ * values.
1912
+ *
1913
+ * @example On range columns
1914
+ * ```ts
1915
+ * const { data, error } = await supabase
1916
+ * .from('reservations')
1917
+ * .select()
1918
+ * .containedBy('during', '[2000-01-01 00:00, 2000-01-01 23:59)')
1919
+ * ```
1920
+ *
1921
+ * @exampleSql On range columns
1922
+ * ```sql
1923
+ * create table
1924
+ * reservations (
1925
+ * id int8 primary key,
1926
+ * room_name text,
1927
+ * during tsrange
1928
+ * );
1929
+ *
1930
+ * insert into
1931
+ * reservations (id, room_name, during)
1932
+ * values
1933
+ * (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
1934
+ * (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
1935
+ * ```
1936
+ *
1937
+ * @exampleResponse On range columns
1938
+ * ```json
1939
+ * {
1940
+ * "data": [
1941
+ * {
1942
+ * "id": 1,
1943
+ * "room_name": "Emerald",
1944
+ * "during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
1945
+ * }
1946
+ * ],
1947
+ * "status": 200,
1948
+ * "statusText": "OK"
1949
+ * }
1950
+ * ```
1951
+ *
1952
+ * @example On `jsonb` columns
1953
+ * ```ts
1954
+ * const { data, error } = await supabase
1955
+ * .from('users')
1956
+ * .select('name')
1957
+ * .containedBy('address', {})
1958
+ * ```
1959
+ *
1960
+ * @exampleSql On `jsonb` columns
1961
+ * ```sql
1962
+ * create table
1963
+ * users (
1964
+ * id int8 primary key,
1965
+ * name text,
1966
+ * address jsonb
1967
+ * );
1968
+ *
1969
+ * insert into
1970
+ * users (id, name, address)
1971
+ * values
1972
+ * (1, 'Michael', '{ "postcode": 90210, "street": "Melrose Place" }'),
1973
+ * (2, 'Jane', '{}');
1974
+ * ```
1975
+ *
1976
+ * @exampleResponse On `jsonb` columns
1977
+ * ```json
1978
+ * {
1979
+ * "data": [
1980
+ * {
1981
+ * "name": "Jane"
1982
+ * }
1983
+ * ],
1984
+ * "status": 200,
1985
+ * "statusText": "OK"
1986
+ * }
1987
+ *
1988
+ * ```
1989
+ */
1990
+ containedBy(column, value) {
1991
+ if (typeof value === "string") this.url.searchParams.append(column, `cd.${value}`);
1992
+ else if (Array.isArray(value)) this.url.searchParams.append(column, `cd.{${value.join(",")}}`);
1993
+ else this.url.searchParams.append(column, `cd.${JSON.stringify(value)}`);
1994
+ return this;
1995
+ }
1996
+ /**
1997
+ * Only relevant for range columns. Match only rows where every element in
1998
+ * `column` is greater than any element in `range`.
1999
+ *
2000
+ * @param column - The range column to filter on
2001
+ * @param range - The range to filter with
2002
+ *
2003
+ * @category Database
2004
+ *
2005
+ * @exampleDescription With `select()`
2006
+ * Postgres supports a number of [range
2007
+ * types](https://www.postgresql.org/docs/current/rangetypes.html). You
2008
+ * can filter on range columns using the string representation of range
2009
+ * values.
2010
+ *
2011
+ * @example With `select()`
2012
+ * ```ts
2013
+ * const { data, error } = await supabase
2014
+ * .from('reservations')
2015
+ * .select()
2016
+ * .rangeGt('during', '[2000-01-02 08:00, 2000-01-02 09:00)')
2017
+ * ```
2018
+ *
2019
+ * @exampleSql With `select()`
2020
+ * ```sql
2021
+ * create table
2022
+ * reservations (
2023
+ * id int8 primary key,
2024
+ * room_name text,
2025
+ * during tsrange
2026
+ * );
2027
+ *
2028
+ * insert into
2029
+ * reservations (id, room_name, during)
2030
+ * values
2031
+ * (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
2032
+ * (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
2033
+ * ```
2034
+ *
2035
+ * @exampleResponse With `select()`
2036
+ * ```json
2037
+ * {
2038
+ * "data": [
2039
+ * {
2040
+ * "id": 2,
2041
+ * "room_name": "Topaz",
2042
+ * "during": "[\"2000-01-02 09:00:00\",\"2000-01-02 10:00:00\")"
2043
+ * }
2044
+ * ],
2045
+ * "status": 200,
2046
+ * "statusText": "OK"
2047
+ * }
2048
+ *
2049
+ * ```
2050
+ */
2051
+ rangeGt(column, range) {
2052
+ this.url.searchParams.append(column, `sr.${range}`);
2053
+ return this;
2054
+ }
2055
+ /**
2056
+ * Only relevant for range columns. Match only rows where every element in
2057
+ * `column` is either contained in `range` or greater than any element in
2058
+ * `range`.
2059
+ *
2060
+ * @param column - The range column to filter on
2061
+ * @param range - The range to filter with
2062
+ *
2063
+ * @category Database
2064
+ *
2065
+ * @exampleDescription With `select()`
2066
+ * Postgres supports a number of [range
2067
+ * types](https://www.postgresql.org/docs/current/rangetypes.html). You
2068
+ * can filter on range columns using the string representation of range
2069
+ * values.
2070
+ *
2071
+ * @example With `select()`
2072
+ * ```ts
2073
+ * const { data, error } = await supabase
2074
+ * .from('reservations')
2075
+ * .select()
2076
+ * .rangeGte('during', '[2000-01-02 08:30, 2000-01-02 09:30)')
2077
+ * ```
2078
+ *
2079
+ * @exampleSql With `select()`
2080
+ * ```sql
2081
+ * create table
2082
+ * reservations (
2083
+ * id int8 primary key,
2084
+ * room_name text,
2085
+ * during tsrange
2086
+ * );
2087
+ *
2088
+ * insert into
2089
+ * reservations (id, room_name, during)
2090
+ * values
2091
+ * (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
2092
+ * (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
2093
+ * ```
2094
+ *
2095
+ * @exampleResponse With `select()`
2096
+ * ```json
2097
+ * {
2098
+ * "data": [
2099
+ * {
2100
+ * "id": 2,
2101
+ * "room_name": "Topaz",
2102
+ * "during": "[\"2000-01-02 09:00:00\",\"2000-01-02 10:00:00\")"
2103
+ * }
2104
+ * ],
2105
+ * "status": 200,
2106
+ * "statusText": "OK"
2107
+ * }
2108
+ *
2109
+ * ```
2110
+ */
2111
+ rangeGte(column, range) {
2112
+ this.url.searchParams.append(column, `nxl.${range}`);
2113
+ return this;
2114
+ }
2115
+ /**
2116
+ * Only relevant for range columns. Match only rows where every element in
2117
+ * `column` is less than any element in `range`.
2118
+ *
2119
+ * @param column - The range column to filter on
2120
+ * @param range - The range to filter with
2121
+ *
2122
+ * @category Database
2123
+ *
2124
+ * @exampleDescription With `select()`
2125
+ * Postgres supports a number of [range
2126
+ * types](https://www.postgresql.org/docs/current/rangetypes.html). You
2127
+ * can filter on range columns using the string representation of range
2128
+ * values.
2129
+ *
2130
+ * @example With `select()`
2131
+ * ```ts
2132
+ * const { data, error } = await supabase
2133
+ * .from('reservations')
2134
+ * .select()
2135
+ * .rangeLt('during', '[2000-01-01 15:00, 2000-01-01 16:00)')
2136
+ * ```
2137
+ *
2138
+ * @exampleSql With `select()`
2139
+ * ```sql
2140
+ * create table
2141
+ * reservations (
2142
+ * id int8 primary key,
2143
+ * room_name text,
2144
+ * during tsrange
2145
+ * );
2146
+ *
2147
+ * insert into
2148
+ * reservations (id, room_name, during)
2149
+ * values
2150
+ * (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
2151
+ * (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
2152
+ * ```
2153
+ *
2154
+ * @exampleResponse With `select()`
2155
+ * ```json
2156
+ * {
2157
+ * "data": [
2158
+ * {
2159
+ * "id": 1,
2160
+ * "room_name": "Emerald",
2161
+ * "during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
2162
+ * }
2163
+ * ],
2164
+ * "status": 200,
2165
+ * "statusText": "OK"
2166
+ * }
2167
+ * ```
2168
+ */
2169
+ rangeLt(column, range) {
2170
+ this.url.searchParams.append(column, `sl.${range}`);
2171
+ return this;
2172
+ }
2173
+ /**
2174
+ * Only relevant for range columns. Match only rows where every element in
2175
+ * `column` is either contained in `range` or less than any element in
2176
+ * `range`.
2177
+ *
2178
+ * @param column - The range column to filter on
2179
+ * @param range - The range to filter with
2180
+ *
2181
+ * @category Database
2182
+ *
2183
+ * @exampleDescription With `select()`
2184
+ * Postgres supports a number of [range
2185
+ * types](https://www.postgresql.org/docs/current/rangetypes.html). You
2186
+ * can filter on range columns using the string representation of range
2187
+ * values.
2188
+ *
2189
+ * @example With `select()`
2190
+ * ```ts
2191
+ * const { data, error } = await supabase
2192
+ * .from('reservations')
2193
+ * .select()
2194
+ * .rangeLte('during', '[2000-01-01 14:00, 2000-01-01 16:00)')
2195
+ * ```
2196
+ *
2197
+ * @exampleSql With `select()`
2198
+ * ```sql
2199
+ * create table
2200
+ * reservations (
2201
+ * id int8 primary key,
2202
+ * room_name text,
2203
+ * during tsrange
2204
+ * );
2205
+ *
2206
+ * insert into
2207
+ * reservations (id, room_name, during)
2208
+ * values
2209
+ * (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
2210
+ * (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
2211
+ * ```
2212
+ *
2213
+ * @exampleResponse With `select()`
2214
+ * ```json
2215
+ * {
2216
+ * "data": [
2217
+ * {
2218
+ * "id": 1,
2219
+ * "room_name": "Emerald",
2220
+ * "during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
2221
+ * }
2222
+ * ],
2223
+ * "status": 200,
2224
+ * "statusText": "OK"
2225
+ * }
2226
+ *
2227
+ * ```
2228
+ */
2229
+ rangeLte(column, range) {
2230
+ this.url.searchParams.append(column, `nxr.${range}`);
2231
+ return this;
2232
+ }
710
2233
  /**
711
2234
  * Only relevant for range columns. Match only rows where `column` is
712
2235
  * mutually exclusive to `range` and there can be no element between the two
@@ -714,6 +2237,53 @@ var PostgrestFilterBuilder = class extends PostgrestTransformBuilder {
714
2237
  *
715
2238
  * @param column - The range column to filter on
716
2239
  * @param range - The range to filter with
2240
+ *
2241
+ * @category Database
2242
+ *
2243
+ * @exampleDescription With `select()`
2244
+ * Postgres supports a number of [range
2245
+ * types](https://www.postgresql.org/docs/current/rangetypes.html). You
2246
+ * can filter on range columns using the string representation of range
2247
+ * values.
2248
+ *
2249
+ * @example With `select()`
2250
+ * ```ts
2251
+ * const { data, error } = await supabase
2252
+ * .from('reservations')
2253
+ * .select()
2254
+ * .rangeAdjacent('during', '[2000-01-01 12:00, 2000-01-01 13:00)')
2255
+ * ```
2256
+ *
2257
+ * @exampleSql With `select()`
2258
+ * ```sql
2259
+ * create table
2260
+ * reservations (
2261
+ * id int8 primary key,
2262
+ * room_name text,
2263
+ * during tsrange
2264
+ * );
2265
+ *
2266
+ * insert into
2267
+ * reservations (id, room_name, during)
2268
+ * values
2269
+ * (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
2270
+ * (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
2271
+ * ```
2272
+ *
2273
+ * @exampleResponse With `select()`
2274
+ * ```json
2275
+ * {
2276
+ * "data": [
2277
+ * {
2278
+ * "id": 1,
2279
+ * "room_name": "Emerald",
2280
+ * "during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
2281
+ * }
2282
+ * ],
2283
+ * "status": 200,
2284
+ * "statusText": "OK"
2285
+ * }
2286
+ * ```
717
2287
  */
718
2288
  rangeAdjacent(column, range) {
719
2289
  this.url.searchParams.append(column, `adj.${range}`);
@@ -723,23 +2293,200 @@ var PostgrestFilterBuilder = class extends PostgrestTransformBuilder {
723
2293
  * Only relevant for array and range columns. Match only rows where
724
2294
  * `column` and `value` have an element in common.
725
2295
  *
726
- * @param column - The array or range column to filter on
727
- * @param value - The array or range value to filter with
728
- */
729
- overlaps(column, value) {
730
- if (typeof value === "string") this.url.searchParams.append(column, `ov.${value}`);
731
- else this.url.searchParams.append(column, `ov.{${value.join(",")}}`);
732
- return this;
733
- }
734
- /**
735
- * Only relevant for text and tsvector columns. Match only rows where
736
- * `column` matches the query string in `query`.
2296
+ * @param column - The array or range column to filter on
2297
+ * @param value - The array or range value to filter with
2298
+ *
2299
+ * @category Database
2300
+ *
2301
+ * @example On array columns
2302
+ * ```ts
2303
+ * const { data, error } = await supabase
2304
+ * .from('issues')
2305
+ * .select('title')
2306
+ * .overlaps('tags', ['is:closed', 'severity:high'])
2307
+ * ```
2308
+ *
2309
+ * @exampleSql On array columns
2310
+ * ```sql
2311
+ * create table
2312
+ * issues (
2313
+ * id int8 primary key,
2314
+ * title text,
2315
+ * tags text[]
2316
+ * );
2317
+ *
2318
+ * insert into
2319
+ * issues (id, title, tags)
2320
+ * values
2321
+ * (1, 'Cache invalidation is not working', array['is:open', 'severity:high', 'priority:low']),
2322
+ * (2, 'Use better names', array['is:open', 'severity:low', 'priority:medium']);
2323
+ * ```
2324
+ *
2325
+ * @exampleResponse On array columns
2326
+ * ```json
2327
+ * {
2328
+ * "data": [
2329
+ * {
2330
+ * "title": "Cache invalidation is not working"
2331
+ * }
2332
+ * ],
2333
+ * "status": 200,
2334
+ * "statusText": "OK"
2335
+ * }
2336
+ * ```
2337
+ *
2338
+ * @exampleDescription On range columns
2339
+ * Postgres supports a number of [range
2340
+ * types](https://www.postgresql.org/docs/current/rangetypes.html). You
2341
+ * can filter on range columns using the string representation of range
2342
+ * values.
2343
+ *
2344
+ * @example On range columns
2345
+ * ```ts
2346
+ * const { data, error } = await supabase
2347
+ * .from('reservations')
2348
+ * .select()
2349
+ * .overlaps('during', '[2000-01-01 12:45, 2000-01-01 13:15)')
2350
+ * ```
2351
+ *
2352
+ * @exampleSql On range columns
2353
+ * ```sql
2354
+ * create table
2355
+ * reservations (
2356
+ * id int8 primary key,
2357
+ * room_name text,
2358
+ * during tsrange
2359
+ * );
2360
+ *
2361
+ * insert into
2362
+ * reservations (id, room_name, during)
2363
+ * values
2364
+ * (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
2365
+ * (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
2366
+ * ```
2367
+ *
2368
+ * @exampleResponse On range columns
2369
+ * ```json
2370
+ * {
2371
+ * "data": [
2372
+ * {
2373
+ * "id": 1,
2374
+ * "room_name": "Emerald",
2375
+ * "during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
2376
+ * }
2377
+ * ],
2378
+ * "status": 200,
2379
+ * "statusText": "OK"
2380
+ * }
2381
+ * ```
2382
+ */
2383
+ overlaps(column, value) {
2384
+ if (typeof value === "string") this.url.searchParams.append(column, `ov.${value}`);
2385
+ else this.url.searchParams.append(column, `ov.{${value.join(",")}}`);
2386
+ return this;
2387
+ }
2388
+ /**
2389
+ * Only relevant for text and tsvector columns. Match only rows where
2390
+ * `column` matches the query string in `query`.
2391
+ *
2392
+ * @param column - The text or tsvector column to filter on
2393
+ * @param query - The query text to match with
2394
+ * @param options - Named parameters
2395
+ * @param options.config - The text search configuration to use
2396
+ * @param options.type - Change how the `query` text is interpreted
2397
+ *
2398
+ * @category Database
2399
+ *
2400
+ * @remarks
2401
+ * - For more information, see [Postgres full text search](/docs/guides/database/full-text-search).
2402
+ *
2403
+ * @example Text search
2404
+ * ```ts
2405
+ * const result = await supabase
2406
+ * .from("texts")
2407
+ * .select("content")
2408
+ * .textSearch("content", `'eggs' & 'ham'`, {
2409
+ * config: "english",
2410
+ * });
2411
+ * ```
2412
+ *
2413
+ * @exampleSql Text search
2414
+ * ```sql
2415
+ * create table texts (
2416
+ * id bigint
2417
+ * primary key
2418
+ * generated always as identity,
2419
+ * content text
2420
+ * );
2421
+ *
2422
+ * insert into texts (content) values
2423
+ * ('Four score and seven years ago'),
2424
+ * ('The road goes ever on and on'),
2425
+ * ('Green eggs and ham')
2426
+ * ;
2427
+ * ```
2428
+ *
2429
+ * @exampleResponse Text search
2430
+ * ```json
2431
+ * {
2432
+ * "data": [
2433
+ * {
2434
+ * "content": "Green eggs and ham"
2435
+ * }
2436
+ * ],
2437
+ * "status": 200,
2438
+ * "statusText": "OK"
2439
+ * }
2440
+ * ```
2441
+ *
2442
+ * @exampleDescription Basic normalization
2443
+ * Uses PostgreSQL's `plainto_tsquery` function.
2444
+ *
2445
+ * @example Basic normalization
2446
+ * ```ts
2447
+ * const { data, error } = await supabase
2448
+ * .from('quotes')
2449
+ * .select('catchphrase')
2450
+ * .textSearch('catchphrase', `'fat' & 'cat'`, {
2451
+ * type: 'plain',
2452
+ * config: 'english'
2453
+ * })
2454
+ * ```
2455
+ *
2456
+ * @exampleDescription Full normalization
2457
+ * Uses PostgreSQL's `phraseto_tsquery` function.
2458
+ *
2459
+ * @example Full normalization
2460
+ * ```ts
2461
+ * const { data, error } = await supabase
2462
+ * .from('quotes')
2463
+ * .select('catchphrase')
2464
+ * .textSearch('catchphrase', `'fat' & 'cat'`, {
2465
+ * type: 'phrase',
2466
+ * config: 'english'
2467
+ * })
2468
+ * ```
2469
+ *
2470
+ * @exampleDescription Websearch
2471
+ * Uses PostgreSQL's `websearch_to_tsquery` function.
2472
+ * This function will never raise syntax errors, which makes it possible to use raw user-supplied input for search, and can be used
2473
+ * with advanced operators.
737
2474
  *
738
- * @param column - The text or tsvector column to filter on
739
- * @param query - The query text to match with
740
- * @param options - Named parameters
741
- * @param options.config - The text search configuration to use
742
- * @param options.type - Change how the `query` text is interpreted
2475
+ * - `unquoted text`: text not inside quote marks will be converted to terms separated by & operators, as if processed by plainto_tsquery.
2476
+ * - `"quoted text"`: text inside quote marks will be converted to terms separated by `<->` operators, as if processed by phraseto_tsquery.
2477
+ * - `OR`: the word “or” will be converted to the | operator.
2478
+ * - `-`: a dash will be converted to the ! operator.
2479
+ *
2480
+ * @example Websearch
2481
+ * ```ts
2482
+ * const { data, error } = await supabase
2483
+ * .from('quotes')
2484
+ * .select('catchphrase')
2485
+ * .textSearch('catchphrase', `'fat or cat'`, {
2486
+ * type: 'websearch',
2487
+ * config: 'english'
2488
+ * })
2489
+ * ```
743
2490
  */
744
2491
  textSearch(column, query, { config, type } = {}) {
745
2492
  let typePart = "";
@@ -756,9 +2503,45 @@ var PostgrestFilterBuilder = class extends PostgrestTransformBuilder {
756
2503
  *
757
2504
  * @param query - The object to filter with, with column names as keys mapped
758
2505
  * to their filter values
2506
+ *
2507
+ * @category Database
2508
+ *
2509
+ * @example With `select()`
2510
+ * ```ts
2511
+ * const { data, error } = await supabase
2512
+ * .from('characters')
2513
+ * .select('name')
2514
+ * .match({ id: 2, name: 'Leia' })
2515
+ * ```
2516
+ *
2517
+ * @exampleSql With `select()`
2518
+ * ```sql
2519
+ * create table
2520
+ * characters (id int8 primary key, name text);
2521
+ *
2522
+ * insert into
2523
+ * characters (id, name)
2524
+ * values
2525
+ * (1, 'Luke'),
2526
+ * (2, 'Leia'),
2527
+ * (3, 'Han');
2528
+ * ```
2529
+ *
2530
+ * @exampleResponse With `select()`
2531
+ * ```json
2532
+ * {
2533
+ * "data": [
2534
+ * {
2535
+ * "name": "Leia"
2536
+ * }
2537
+ * ],
2538
+ * "status": 200,
2539
+ * "statusText": "OK"
2540
+ * }
2541
+ * ```
759
2542
  */
760
2543
  match(query) {
761
- Object.entries(query).forEach(([column, value]) => {
2544
+ Object.entries(query).filter(([_, value]) => value !== void 0).forEach(([column, value]) => {
762
2545
  this.url.searchParams.append(column, `eq.${value}`);
763
2546
  });
764
2547
  return this;
@@ -775,6 +2558,51 @@ var PostgrestFilterBuilder = class extends PostgrestTransformBuilder {
775
2558
  * @param operator - The operator to be negated to filter with, following
776
2559
  * PostgREST syntax
777
2560
  * @param value - The value to filter with, following PostgREST syntax
2561
+ *
2562
+ * @category Database
2563
+ *
2564
+ * @remarks
2565
+ * not() expects you to use the raw PostgREST syntax for the filter values.
2566
+ *
2567
+ * ```ts
2568
+ * .not('id', 'in', '(5,6,7)') // Use `()` for `in` filter
2569
+ * .not('arraycol', 'cs', '{"a","b"}') // Use `cs` for `contains()`, `{}` for array values
2570
+ * ```
2571
+ *
2572
+ * @example With `select()`
2573
+ * ```ts
2574
+ * const { data, error } = await supabase
2575
+ * .from('countries')
2576
+ * .select()
2577
+ * .not('name', 'is', null)
2578
+ * ```
2579
+ *
2580
+ * @exampleSql With `select()`
2581
+ * ```sql
2582
+ * create table
2583
+ * countries (id int8 primary key, name text);
2584
+ *
2585
+ * insert into
2586
+ * countries (id, name)
2587
+ * values
2588
+ * (1, 'null'),
2589
+ * (2, null);
2590
+ * ```
2591
+ *
2592
+ * @exampleResponse With `select()`
2593
+ * ```json
2594
+ * {
2595
+ * "data": [
2596
+ * {
2597
+ * "id": 1,
2598
+ * "name": "null"
2599
+ * }
2600
+ * ],
2601
+ * "status": 200,
2602
+ * "statusText": "OK"
2603
+ * }
2604
+ *
2605
+ * ```
778
2606
  */
779
2607
  not(column, operator, value) {
780
2608
  this.url.searchParams.append(column, `not.${operator}.${value}`);
@@ -787,31 +2615,265 @@ var PostgrestFilterBuilder = class extends PostgrestTransformBuilder {
787
2615
  * syntax](https://postgrest.org/en/stable/api.html#operators). You also need
788
2616
  * to make sure it's properly sanitized.
789
2617
  *
790
- * It's currently not possible to do an `.or()` filter across multiple tables.
2618
+ * It's currently not possible to do an `.or()` filter across multiple tables.
2619
+ *
2620
+ * @param filters - The filters to use, following PostgREST syntax
2621
+ * @param options - Named parameters
2622
+ * @param options.referencedTable - Set this to filter on referenced tables
2623
+ * instead of the parent table
2624
+ * @param options.foreignTable - Deprecated, use `referencedTable` instead
2625
+ *
2626
+ * @category Database
2627
+ *
2628
+ * @remarks
2629
+ * or() expects you to use the raw PostgREST syntax for the filter names and values.
2630
+ *
2631
+ * ```ts
2632
+ * .or('id.in.(5,6,7), arraycol.cs.{"a","b"}') // Use `()` for `in` filter, `{}` for array values and `cs` for `contains()`.
2633
+ * .or('id.in.(5,6,7), arraycol.cd.{"a","b"}') // Use `cd` for `containedBy()`
2634
+ * ```
2635
+ *
2636
+ * @example With `select()`
2637
+ * ```ts
2638
+ * const { data, error } = await supabase
2639
+ * .from('characters')
2640
+ * .select('name')
2641
+ * .or('id.eq.2,name.eq.Han')
2642
+ * ```
2643
+ *
2644
+ * @exampleSql With `select()`
2645
+ * ```sql
2646
+ * create table
2647
+ * characters (id int8 primary key, name text);
2648
+ *
2649
+ * insert into
2650
+ * characters (id, name)
2651
+ * values
2652
+ * (1, 'Luke'),
2653
+ * (2, 'Leia'),
2654
+ * (3, 'Han');
2655
+ * ```
2656
+ *
2657
+ * @exampleResponse With `select()`
2658
+ * ```json
2659
+ * {
2660
+ * "data": [
2661
+ * {
2662
+ * "name": "Leia"
2663
+ * },
2664
+ * {
2665
+ * "name": "Han"
2666
+ * }
2667
+ * ],
2668
+ * "status": 200,
2669
+ * "statusText": "OK"
2670
+ * }
2671
+ * ```
2672
+ *
2673
+ * @example Use `or` with `and`
2674
+ * ```ts
2675
+ * const { data, error } = await supabase
2676
+ * .from('characters')
2677
+ * .select('name')
2678
+ * .or('id.gt.3,and(id.eq.1,name.eq.Luke)')
2679
+ * ```
2680
+ *
2681
+ * @exampleSql Use `or` with `and`
2682
+ * ```sql
2683
+ * create table
2684
+ * characters (id int8 primary key, name text);
2685
+ *
2686
+ * insert into
2687
+ * characters (id, name)
2688
+ * values
2689
+ * (1, 'Luke'),
2690
+ * (2, 'Leia'),
2691
+ * (3, 'Han');
2692
+ * ```
2693
+ *
2694
+ * @exampleResponse Use `or` with `and`
2695
+ * ```json
2696
+ * {
2697
+ * "data": [
2698
+ * {
2699
+ * "name": "Luke"
2700
+ * }
2701
+ * ],
2702
+ * "status": 200,
2703
+ * "statusText": "OK"
2704
+ * }
2705
+ * ```
2706
+ *
2707
+ * @example Use `or` on referenced tables
2708
+ * ```ts
2709
+ * const { data, error } = await supabase
2710
+ * .from('orchestral_sections')
2711
+ * .select(`
2712
+ * name,
2713
+ * instruments!inner (
2714
+ * name
2715
+ * )
2716
+ * `)
2717
+ * .or('section_id.eq.1,name.eq.guzheng', { referencedTable: 'instruments' })
2718
+ * ```
2719
+ *
2720
+ * @exampleSql Use `or` on referenced tables
2721
+ * ```sql
2722
+ * create table
2723
+ * orchestral_sections (id int8 primary key, name text);
2724
+ * create table
2725
+ * instruments (
2726
+ * id int8 primary key,
2727
+ * section_id int8 not null references orchestral_sections,
2728
+ * name text
2729
+ * );
2730
+ *
2731
+ * insert into
2732
+ * orchestral_sections (id, name)
2733
+ * values
2734
+ * (1, 'strings'),
2735
+ * (2, 'woodwinds');
2736
+ * insert into
2737
+ * instruments (id, section_id, name)
2738
+ * values
2739
+ * (1, 2, 'flute'),
2740
+ * (2, 1, 'violin');
2741
+ * ```
2742
+ *
2743
+ * @exampleResponse Use `or` on referenced tables
2744
+ * ```json
2745
+ * {
2746
+ * "data": [
2747
+ * {
2748
+ * "name": "strings",
2749
+ * "instruments": [
2750
+ * {
2751
+ * "name": "violin"
2752
+ * }
2753
+ * ]
2754
+ * }
2755
+ * ],
2756
+ * "status": 200,
2757
+ * "statusText": "OK"
2758
+ * }
2759
+ * ```
2760
+ */
2761
+ or(filters, { foreignTable, referencedTable = foreignTable } = {}) {
2762
+ const key = referencedTable ? `${referencedTable}.or` : "or";
2763
+ this.url.searchParams.append(key, `(${filters})`);
2764
+ return this;
2765
+ }
2766
+ /**
2767
+ * Match only rows which satisfy the filter. This is an escape hatch - you
2768
+ * should use the specific filter methods wherever possible.
2769
+ *
2770
+ * Unlike most filters, `opearator` and `value` are used as-is and need to
2771
+ * follow [PostgREST
2772
+ * syntax](https://postgrest.org/en/stable/api.html#operators). You also need
2773
+ * to make sure they are properly sanitized.
2774
+ *
2775
+ * @param column - The column to filter on
2776
+ * @param operator - The operator to filter with, following PostgREST syntax
2777
+ * @param value - The value to filter with, following PostgREST syntax
2778
+ *
2779
+ * @category Database
2780
+ *
2781
+ * @remarks
2782
+ * filter() expects you to use the raw PostgREST syntax for the filter values.
2783
+ *
2784
+ * ```ts
2785
+ * .filter('id', 'in', '(5,6,7)') // Use `()` for `in` filter
2786
+ * .filter('arraycol', 'cs', '{"a","b"}') // Use `cs` for `contains()`, `{}` for array values
2787
+ * ```
2788
+ *
2789
+ * @example With `select()`
2790
+ * ```ts
2791
+ * const { data, error } = await supabase
2792
+ * .from('characters')
2793
+ * .select()
2794
+ * .filter('name', 'in', '("Han","Yoda")')
2795
+ * ```
2796
+ *
2797
+ * @exampleSql With `select()`
2798
+ * ```sql
2799
+ * create table
2800
+ * characters (id int8 primary key, name text);
2801
+ *
2802
+ * insert into
2803
+ * characters (id, name)
2804
+ * values
2805
+ * (1, 'Luke'),
2806
+ * (2, 'Leia'),
2807
+ * (3, 'Han');
2808
+ * ```
2809
+ *
2810
+ * @exampleResponse With `select()`
2811
+ * ```json
2812
+ * {
2813
+ * "data": [
2814
+ * {
2815
+ * "id": 3,
2816
+ * "name": "Han"
2817
+ * }
2818
+ * ],
2819
+ * "status": 200,
2820
+ * "statusText": "OK"
2821
+ * }
2822
+ * ```
2823
+ *
2824
+ * @example On a referenced table
2825
+ * ```ts
2826
+ * const { data, error } = await supabase
2827
+ * .from('orchestral_sections')
2828
+ * .select(`
2829
+ * name,
2830
+ * instruments!inner (
2831
+ * name
2832
+ * )
2833
+ * `)
2834
+ * .filter('instruments.name', 'eq', 'flute')
2835
+ * ```
791
2836
  *
792
- * @param filters - The filters to use, following PostgREST syntax
793
- * @param options - Named parameters
794
- * @param options.referencedTable - Set this to filter on referenced tables
795
- * instead of the parent table
796
- * @param options.foreignTable - Deprecated, use `referencedTable` instead
797
- */
798
- or(filters, { foreignTable, referencedTable = foreignTable } = {}) {
799
- const key = referencedTable ? `${referencedTable}.or` : "or";
800
- this.url.searchParams.append(key, `(${filters})`);
801
- return this;
802
- }
803
- /**
804
- * Match only rows which satisfy the filter. This is an escape hatch - you
805
- * should use the specific filter methods wherever possible.
2837
+ * @exampleSql On a referenced table
2838
+ * ```sql
2839
+ * create table
2840
+ * orchestral_sections (id int8 primary key, name text);
2841
+ * create table
2842
+ * instruments (
2843
+ * id int8 primary key,
2844
+ * section_id int8 not null references orchestral_sections,
2845
+ * name text
2846
+ * );
806
2847
  *
807
- * Unlike most filters, `opearator` and `value` are used as-is and need to
808
- * follow [PostgREST
809
- * syntax](https://postgrest.org/en/stable/api.html#operators). You also need
810
- * to make sure they are properly sanitized.
2848
+ * insert into
2849
+ * orchestral_sections (id, name)
2850
+ * values
2851
+ * (1, 'strings'),
2852
+ * (2, 'woodwinds');
2853
+ * insert into
2854
+ * instruments (id, section_id, name)
2855
+ * values
2856
+ * (1, 2, 'flute'),
2857
+ * (2, 1, 'violin');
2858
+ * ```
811
2859
  *
812
- * @param column - The column to filter on
813
- * @param operator - The operator to filter with, following PostgREST syntax
814
- * @param value - The value to filter with, following PostgREST syntax
2860
+ * @exampleResponse On a referenced table
2861
+ * ```json
2862
+ * {
2863
+ * "data": [
2864
+ * {
2865
+ * "name": "woodwinds",
2866
+ * "instruments": [
2867
+ * {
2868
+ * "name": "flute"
2869
+ * }
2870
+ * ]
2871
+ * }
2872
+ * ],
2873
+ * "status": 200,
2874
+ * "statusText": "OK"
2875
+ * }
2876
+ * ```
815
2877
  */
816
2878
  filter(column, operator, value) {
817
2879
  this.url.searchParams.append(column, `${operator}.${value}`);
@@ -825,9 +2887,11 @@ var PostgrestQueryBuilder = class {
825
2887
  /**
826
2888
  * Creates a query builder scoped to a Postgres table or view.
827
2889
  *
828
- * @example
2890
+ * @category Database
2891
+ *
2892
+ * @example Creating a Postgrest query builder
829
2893
  * ```ts
830
- * import PostgrestQueryBuilder from '@supabase/postgrest-js'
2894
+ * import { PostgrestQueryBuilder } from '@supabase/postgrest-js'
831
2895
  *
832
2896
  * const query = new PostgrestQueryBuilder(
833
2897
  * new URL('https://xyzcompany.supabase.co/rest/v1/users'),
@@ -2190,6 +4254,105 @@ var PostgrestQueryBuilder = class {
2190
4254
  *
2191
4255
  * `"estimated"`: Uses exact count for low numbers and planned count for high
2192
4256
  * numbers.
4257
+ *
4258
+ * @category Database
4259
+ *
4260
+ * @remarks
4261
+ * - `delete()` should always be combined with [filters](/docs/reference/javascript/using-filters) to target the item(s) you wish to delete.
4262
+ * - If you use `delete()` with filters and you have
4263
+ * [RLS](/docs/learn/auth-deep-dive/auth-row-level-security) enabled, only
4264
+ * rows visible through `SELECT` policies are deleted. Note that by default
4265
+ * no rows are visible, so you need at least one `SELECT`/`ALL` policy that
4266
+ * makes the rows visible.
4267
+ * - When using `delete().in()`, specify an array of values to target multiple rows with a single query. This is particularly useful for batch deleting entries that share common criteria, such as deleting users by their IDs. Ensure that the array you provide accurately represents all records you intend to delete to avoid unintended data removal.
4268
+ *
4269
+ * @example Delete a single record
4270
+ * ```ts
4271
+ * const response = await supabase
4272
+ * .from('countries')
4273
+ * .delete()
4274
+ * .eq('id', 1)
4275
+ * ```
4276
+ *
4277
+ * @exampleSql Delete a single record
4278
+ * ```sql
4279
+ * create table
4280
+ * countries (id int8 primary key, name text);
4281
+ *
4282
+ * insert into
4283
+ * countries (id, name)
4284
+ * values
4285
+ * (1, 'Mordor');
4286
+ * ```
4287
+ *
4288
+ * @exampleResponse Delete a single record
4289
+ * ```json
4290
+ * {
4291
+ * "status": 204,
4292
+ * "statusText": "No Content"
4293
+ * }
4294
+ * ```
4295
+ *
4296
+ * @example Delete a record and return it
4297
+ * ```ts
4298
+ * const { data, error } = await supabase
4299
+ * .from('countries')
4300
+ * .delete()
4301
+ * .eq('id', 1)
4302
+ * .select()
4303
+ * ```
4304
+ *
4305
+ * @exampleSql Delete a record and return it
4306
+ * ```sql
4307
+ * create table
4308
+ * countries (id int8 primary key, name text);
4309
+ *
4310
+ * insert into
4311
+ * countries (id, name)
4312
+ * values
4313
+ * (1, 'Mordor');
4314
+ * ```
4315
+ *
4316
+ * @exampleResponse Delete a record and return it
4317
+ * ```json
4318
+ * {
4319
+ * "data": [
4320
+ * {
4321
+ * "id": 1,
4322
+ * "name": "Mordor"
4323
+ * }
4324
+ * ],
4325
+ * "status": 200,
4326
+ * "statusText": "OK"
4327
+ * }
4328
+ * ```
4329
+ *
4330
+ * @example Delete multiple records
4331
+ * ```ts
4332
+ * const response = await supabase
4333
+ * .from('countries')
4334
+ * .delete()
4335
+ * .in('id', [1, 2, 3])
4336
+ * ```
4337
+ *
4338
+ * @exampleSql Delete multiple records
4339
+ * ```sql
4340
+ * create table
4341
+ * countries (id int8 primary key, name text);
4342
+ *
4343
+ * insert into
4344
+ * countries (id, name)
4345
+ * values
4346
+ * (1, 'Rohan'), (2, 'The Shire'), (3, 'Mordor');
4347
+ * ```
4348
+ *
4349
+ * @exampleResponse Delete multiple records
4350
+ * ```json
4351
+ * {
4352
+ * "status": 204,
4353
+ * "statusText": "No Content"
4354
+ * }
4355
+ * ```
2193
4356
  */
2194
4357
  delete({ count } = {}) {
2195
4358
  var _this$fetch4;
@@ -2298,7 +4461,34 @@ var PostgrestClient = class PostgrestClient {
2298
4461
  * @param options.urlLengthLimit - Maximum URL length in characters before warnings/errors are triggered. Defaults to 8000.
2299
4462
  * @example
2300
4463
  * ```ts
2301
- * import PostgrestClient from '@supabase/postgrest-js'
4464
+ * import { PostgrestClient } from '@supabase/postgrest-js'
4465
+ *
4466
+ * const postgrest = new PostgrestClient('https://xyzcompany.supabase.co/rest/v1', {
4467
+ * headers: { apikey: 'public-anon-key' },
4468
+ * schema: 'public',
4469
+ * timeout: 30000, // 30 second timeout
4470
+ * })
4471
+ * ```
4472
+ *
4473
+ * @category Database
4474
+ *
4475
+ * @remarks
4476
+ * - A `timeout` option (in milliseconds) can be set to automatically abort requests that take too long.
4477
+ * - A `urlLengthLimit` option (default: 8000) can be set to control when URL length warnings are included in error messages for aborted requests.
4478
+ *
4479
+ * @example Creating a Postgrest client
4480
+ * ```ts
4481
+ * import { PostgrestClient } from '@supabase/postgrest-js'
4482
+ *
4483
+ * const postgrest = new PostgrestClient('https://xyzcompany.supabase.co/rest/v1', {
4484
+ * headers: { apikey: 'public-anon-key' },
4485
+ * schema: 'public',
4486
+ * })
4487
+ * ```
4488
+ *
4489
+ * @example With timeout
4490
+ * ```ts
4491
+ * import { PostgrestClient } from '@supabase/postgrest-js'
2302
4492
  *
2303
4493
  * const postgrest = new PostgrestClient('https://xyzcompany.supabase.co/rest/v1', {
2304
4494
  * headers: { apikey: 'public-anon-key' },
@@ -2340,6 +4530,8 @@ var PostgrestClient = class PostgrestClient {
2340
4530
  * Perform a query on a table or a view.
2341
4531
  *
2342
4532
  * @param relation - The table or view name to query
4533
+ *
4534
+ * @category Database
2343
4535
  */
2344
4536
  from(relation) {
2345
4537
  if (!relation || typeof relation !== "string" || relation.trim() === "") throw new Error("Invalid relation name: relation must be a non-empty string.");
@@ -2356,6 +4548,8 @@ var PostgrestClient = class PostgrestClient {
2356
4548
  * The schema needs to be on the list of exposed schemas inside Supabase.
2357
4549
  *
2358
4550
  * @param schema - The schema to query
4551
+ *
4552
+ * @category Database
2359
4553
  */
2360
4554
  schema(schema) {
2361
4555
  return new PostgrestClient(this.url, {
@@ -2396,6 +4590,139 @@ var PostgrestClient = class PostgrestClient {
2396
4590
  * .rpc('function_a', {})
2397
4591
  * .overrideTypes<{ id: string; user_id: string }[]>()
2398
4592
  * ```
4593
+ *
4594
+ * @category Database
4595
+ *
4596
+ * @example Call a Postgres function without arguments
4597
+ * ```ts
4598
+ * const { data, error } = await supabase.rpc('hello_world')
4599
+ * ```
4600
+ *
4601
+ * @exampleSql Call a Postgres function without arguments
4602
+ * ```sql
4603
+ * create function hello_world() returns text as $$
4604
+ * select 'Hello world';
4605
+ * $$ language sql;
4606
+ * ```
4607
+ *
4608
+ * @exampleResponse Call a Postgres function without arguments
4609
+ * ```json
4610
+ * {
4611
+ * "data": "Hello world",
4612
+ * "status": 200,
4613
+ * "statusText": "OK"
4614
+ * }
4615
+ * ```
4616
+ *
4617
+ * @example Call a Postgres function with arguments
4618
+ * ```ts
4619
+ * const { data, error } = await supabase.rpc('echo', { say: '👋' })
4620
+ * ```
4621
+ *
4622
+ * @exampleSql Call a Postgres function with arguments
4623
+ * ```sql
4624
+ * create function echo(say text) returns text as $$
4625
+ * select say;
4626
+ * $$ language sql;
4627
+ * ```
4628
+ *
4629
+ * @exampleResponse Call a Postgres function with arguments
4630
+ * ```json
4631
+ * {
4632
+ * "data": "👋",
4633
+ * "status": 200,
4634
+ * "statusText": "OK"
4635
+ * }
4636
+ *
4637
+ * ```
4638
+ *
4639
+ * @exampleDescription Bulk processing
4640
+ * You can process large payloads by passing in an array as an argument.
4641
+ *
4642
+ * @example Bulk processing
4643
+ * ```ts
4644
+ * const { data, error } = await supabase.rpc('add_one_each', { arr: [1, 2, 3] })
4645
+ * ```
4646
+ *
4647
+ * @exampleSql Bulk processing
4648
+ * ```sql
4649
+ * create function add_one_each(arr int[]) returns int[] as $$
4650
+ * select array_agg(n + 1) from unnest(arr) as n;
4651
+ * $$ language sql;
4652
+ * ```
4653
+ *
4654
+ * @exampleResponse Bulk processing
4655
+ * ```json
4656
+ * {
4657
+ * "data": [
4658
+ * 2,
4659
+ * 3,
4660
+ * 4
4661
+ * ],
4662
+ * "status": 200,
4663
+ * "statusText": "OK"
4664
+ * }
4665
+ * ```
4666
+ *
4667
+ * @exampleDescription Call a Postgres function with filters
4668
+ * Postgres functions that return tables can also be combined with [Filters](/docs/reference/javascript/using-filters) and [Modifiers](/docs/reference/javascript/using-modifiers).
4669
+ *
4670
+ * @example Call a Postgres function with filters
4671
+ * ```ts
4672
+ * const { data, error } = await supabase
4673
+ * .rpc('list_stored_countries')
4674
+ * .eq('id', 1)
4675
+ * .single()
4676
+ * ```
4677
+ *
4678
+ * @exampleSql Call a Postgres function with filters
4679
+ * ```sql
4680
+ * create table
4681
+ * countries (id int8 primary key, name text);
4682
+ *
4683
+ * insert into
4684
+ * countries (id, name)
4685
+ * values
4686
+ * (1, 'Rohan'),
4687
+ * (2, 'The Shire');
4688
+ *
4689
+ * create function list_stored_countries() returns setof countries as $$
4690
+ * select * from countries;
4691
+ * $$ language sql;
4692
+ * ```
4693
+ *
4694
+ * @exampleResponse Call a Postgres function with filters
4695
+ * ```json
4696
+ * {
4697
+ * "data": {
4698
+ * "id": 1,
4699
+ * "name": "Rohan"
4700
+ * },
4701
+ * "status": 200,
4702
+ * "statusText": "OK"
4703
+ * }
4704
+ * ```
4705
+ *
4706
+ * @example Call a read-only Postgres function
4707
+ * ```ts
4708
+ * const { data, error } = await supabase.rpc('hello_world', undefined, { get: true })
4709
+ * ```
4710
+ *
4711
+ * @exampleSql Call a read-only Postgres function
4712
+ * ```sql
4713
+ * create function hello_world() returns text as $$
4714
+ * select 'Hello world';
4715
+ * $$ language sql;
4716
+ * ```
4717
+ *
4718
+ * @exampleResponse Call a read-only Postgres function
4719
+ * ```json
4720
+ * {
4721
+ * "data": "Hello world",
4722
+ * "status": 200,
4723
+ * "statusText": "OK"
4724
+ * }
4725
+ * ```
2399
4726
  */
2400
4727
  rpc(fn, args = {}, { head = false, get = false, count } = {}) {
2401
4728
  var _this$fetch;