@supabase/postgrest-js 2.99.2 → 2.99.3

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