@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.
@@ -100,6 +100,43 @@ export default class PostgrestFilterBuilder<
100
100
  *
101
101
  * @param column - The column to filter on
102
102
  * @param value - The value to filter with
103
+ *
104
+ * @category Database
105
+ *
106
+ * @example With `select()`
107
+ * ```ts
108
+ * const { data, error } = await supabase
109
+ * .from('characters')
110
+ * .select()
111
+ * .eq('name', 'Leia')
112
+ * ```
113
+ *
114
+ * @exampleSql With `select()`
115
+ * ```sql
116
+ * create table
117
+ * characters (id int8 primary key, name text);
118
+ *
119
+ * insert into
120
+ * characters (id, name)
121
+ * values
122
+ * (1, 'Luke'),
123
+ * (2, 'Leia'),
124
+ * (3, 'Han');
125
+ * ```
126
+ *
127
+ * @exampleResponse With `select()`
128
+ * ```json
129
+ * {
130
+ * "data": [
131
+ * {
132
+ * "id": 2,
133
+ * "name": "Leia"
134
+ * }
135
+ * ],
136
+ * "status": 200,
137
+ * "statusText": "OK"
138
+ * }
139
+ * ```
103
140
  */
104
141
  eq<ColumnName extends string>(
105
142
  column: ColumnName,
@@ -121,6 +158,47 @@ export default class PostgrestFilterBuilder<
121
158
  *
122
159
  * @param column - The column to filter on
123
160
  * @param value - The value to filter with
161
+ *
162
+ * @category Database
163
+ *
164
+ * @example With `select()`
165
+ * ```ts
166
+ * const { data, error } = await supabase
167
+ * .from('characters')
168
+ * .select()
169
+ * .neq('name', 'Leia')
170
+ * ```
171
+ *
172
+ * @exampleSql With `select()`
173
+ * ```sql
174
+ * create table
175
+ * characters (id int8 primary key, name text);
176
+ *
177
+ * insert into
178
+ * characters (id, name)
179
+ * values
180
+ * (1, 'Luke'),
181
+ * (2, 'Leia'),
182
+ * (3, 'Han');
183
+ * ```
184
+ *
185
+ * @exampleResponse With `select()`
186
+ * ```json
187
+ * {
188
+ * "data": [
189
+ * {
190
+ * "id": 1,
191
+ * "name": "Luke"
192
+ * },
193
+ * {
194
+ * "id": 3,
195
+ * "name": "Han"
196
+ * }
197
+ * ],
198
+ * "status": 200,
199
+ * "statusText": "OK"
200
+ * }
201
+ * ```
124
202
  */
125
203
  neq<ColumnName extends string>(
126
204
  column: ColumnName,
@@ -141,6 +219,47 @@ export default class PostgrestFilterBuilder<
141
219
  *
142
220
  * @param column - The column to filter on
143
221
  * @param value - The value to filter with
222
+ *
223
+ * @category Database
224
+ *
225
+ * @exampleDescription With `select()`
226
+ * When using [reserved words](https://www.postgresql.org/docs/current/sql-keywords-appendix.html) for column names you need
227
+ * to add double quotes e.g. `.gt('"order"', 2)`
228
+ *
229
+ * @example With `select()`
230
+ * ```ts
231
+ * const { data, error } = await supabase
232
+ * .from('characters')
233
+ * .select()
234
+ * .gt('id', 2)
235
+ * ```
236
+ *
237
+ * @exampleSql With `select()`
238
+ * ```sql
239
+ * create table
240
+ * characters (id int8 primary key, name text);
241
+ *
242
+ * insert into
243
+ * characters (id, name)
244
+ * values
245
+ * (1, 'Luke'),
246
+ * (2, 'Leia'),
247
+ * (3, 'Han');
248
+ * ```
249
+ *
250
+ * @exampleResponse With `select()`
251
+ * ```json
252
+ * {
253
+ * "data": [
254
+ * {
255
+ * "id": 3,
256
+ * "name": "Han"
257
+ * }
258
+ * ],
259
+ * "status": 200,
260
+ * "statusText": "OK"
261
+ * }
262
+ * ```
144
263
  */
145
264
  gt(column: string, value: unknown): this {
146
265
  this.url.searchParams.append(column, `gt.${value}`)
@@ -154,6 +273,47 @@ export default class PostgrestFilterBuilder<
154
273
  *
155
274
  * @param column - The column to filter on
156
275
  * @param value - The value to filter with
276
+ *
277
+ * @category Database
278
+ *
279
+ * @example With `select()`
280
+ * ```ts
281
+ * const { data, error } = await supabase
282
+ * .from('characters')
283
+ * .select()
284
+ * .gte('id', 2)
285
+ * ```
286
+ *
287
+ * @exampleSql With `select()`
288
+ * ```sql
289
+ * create table
290
+ * characters (id int8 primary key, name text);
291
+ *
292
+ * insert into
293
+ * characters (id, name)
294
+ * values
295
+ * (1, 'Luke'),
296
+ * (2, 'Leia'),
297
+ * (3, 'Han');
298
+ * ```
299
+ *
300
+ * @exampleResponse With `select()`
301
+ * ```json
302
+ * {
303
+ * "data": [
304
+ * {
305
+ * "id": 2,
306
+ * "name": "Leia"
307
+ * },
308
+ * {
309
+ * "id": 3,
310
+ * "name": "Han"
311
+ * }
312
+ * ],
313
+ * "status": 200,
314
+ * "statusText": "OK"
315
+ * }
316
+ * ```
157
317
  */
158
318
  gte(column: string, value: unknown): this {
159
319
  this.url.searchParams.append(column, `gte.${value}`)
@@ -167,6 +327,43 @@ export default class PostgrestFilterBuilder<
167
327
  *
168
328
  * @param column - The column to filter on
169
329
  * @param value - The value to filter with
330
+ *
331
+ * @category Database
332
+ *
333
+ * @example With `select()`
334
+ * ```ts
335
+ * const { data, error } = await supabase
336
+ * .from('characters')
337
+ * .select()
338
+ * .lt('id', 2)
339
+ * ```
340
+ *
341
+ * @exampleSql With `select()`
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, 'Luke'),
350
+ * (2, 'Leia'),
351
+ * (3, 'Han');
352
+ * ```
353
+ *
354
+ * @exampleResponse With `select()`
355
+ * ```json
356
+ * {
357
+ * "data": [
358
+ * {
359
+ * "id": 1,
360
+ * "name": "Luke"
361
+ * }
362
+ * ],
363
+ * "status": 200,
364
+ * "statusText": "OK"
365
+ * }
366
+ * ```
170
367
  */
171
368
  lt(column: string, value: unknown): this {
172
369
  this.url.searchParams.append(column, `lt.${value}`)
@@ -180,6 +377,47 @@ export default class PostgrestFilterBuilder<
180
377
  *
181
378
  * @param column - The column to filter on
182
379
  * @param value - The value to filter with
380
+ *
381
+ * @category Database
382
+ *
383
+ * @example With `select()`
384
+ * ```ts
385
+ * const { data, error } = await supabase
386
+ * .from('characters')
387
+ * .select()
388
+ * .lte('id', 2)
389
+ * ```
390
+ *
391
+ * @exampleSql With `select()`
392
+ * ```sql
393
+ * create table
394
+ * characters (id int8 primary key, name text);
395
+ *
396
+ * insert into
397
+ * characters (id, name)
398
+ * values
399
+ * (1, 'Luke'),
400
+ * (2, 'Leia'),
401
+ * (3, 'Han');
402
+ * ```
403
+ *
404
+ * @exampleResponse With `select()`
405
+ * ```json
406
+ * {
407
+ * "data": [
408
+ * {
409
+ * "id": 1,
410
+ * "name": "Luke"
411
+ * },
412
+ * {
413
+ * "id": 2,
414
+ * "name": "Leia"
415
+ * }
416
+ * ],
417
+ * "status": 200,
418
+ * "statusText": "OK"
419
+ * }
420
+ * ```
183
421
  */
184
422
  lte(column: string, value: unknown): this {
185
423
  this.url.searchParams.append(column, `lte.${value}`)
@@ -193,6 +431,43 @@ export default class PostgrestFilterBuilder<
193
431
  *
194
432
  * @param column - The column to filter on
195
433
  * @param pattern - The pattern to match with
434
+ *
435
+ * @category Database
436
+ *
437
+ * @example With `select()`
438
+ * ```ts
439
+ * const { data, error } = await supabase
440
+ * .from('characters')
441
+ * .select()
442
+ * .like('name', '%Lu%')
443
+ * ```
444
+ *
445
+ * @exampleSql With `select()`
446
+ * ```sql
447
+ * create table
448
+ * characters (id int8 primary key, name text);
449
+ *
450
+ * insert into
451
+ * characters (id, name)
452
+ * values
453
+ * (1, 'Luke'),
454
+ * (2, 'Leia'),
455
+ * (3, 'Han');
456
+ * ```
457
+ *
458
+ * @exampleResponse With `select()`
459
+ * ```json
460
+ * {
461
+ * "data": [
462
+ * {
463
+ * "id": 1,
464
+ * "name": "Luke"
465
+ * }
466
+ * ],
467
+ * "status": 200,
468
+ * "statusText": "OK"
469
+ * }
470
+ * ```
196
471
  */
197
472
  like(column: string, pattern: string): this {
198
473
  this.url.searchParams.append(column, `like.${pattern}`)
@@ -209,6 +484,8 @@ export default class PostgrestFilterBuilder<
209
484
  *
210
485
  * @param column - The column to filter on
211
486
  * @param patterns - The patterns to match with
487
+ *
488
+ * @category Database
212
489
  */
213
490
  likeAllOf(column: string, patterns: readonly string[]): this {
214
491
  this.url.searchParams.append(column, `like(all).{${patterns.join(',')}}`)
@@ -225,6 +502,8 @@ export default class PostgrestFilterBuilder<
225
502
  *
226
503
  * @param column - The column to filter on
227
504
  * @param patterns - The patterns to match with
505
+ *
506
+ * @category Database
228
507
  */
229
508
  likeAnyOf(column: string, patterns: readonly string[]): this {
230
509
  this.url.searchParams.append(column, `like(any).{${patterns.join(',')}}`)
@@ -238,6 +517,43 @@ export default class PostgrestFilterBuilder<
238
517
  *
239
518
  * @param column - The column to filter on
240
519
  * @param pattern - The pattern to match with
520
+ *
521
+ * @category Database
522
+ *
523
+ * @example With `select()`
524
+ * ```ts
525
+ * const { data, error } = await supabase
526
+ * .from('characters')
527
+ * .select()
528
+ * .ilike('name', '%lu%')
529
+ * ```
530
+ *
531
+ * @exampleSql With `select()`
532
+ * ```sql
533
+ * create table
534
+ * characters (id int8 primary key, name text);
535
+ *
536
+ * insert into
537
+ * characters (id, name)
538
+ * values
539
+ * (1, 'Luke'),
540
+ * (2, 'Leia'),
541
+ * (3, 'Han');
542
+ * ```
543
+ *
544
+ * @exampleResponse With `select()`
545
+ * ```json
546
+ * {
547
+ * "data": [
548
+ * {
549
+ * "id": 1,
550
+ * "name": "Luke"
551
+ * }
552
+ * ],
553
+ * "status": 200,
554
+ * "statusText": "OK"
555
+ * }
556
+ * ```
241
557
  */
242
558
  ilike(column: string, pattern: string): this {
243
559
  this.url.searchParams.append(column, `ilike.${pattern}`)
@@ -254,6 +570,8 @@ export default class PostgrestFilterBuilder<
254
570
  *
255
571
  * @param column - The column to filter on
256
572
  * @param patterns - The patterns to match with
573
+ *
574
+ * @category Database
257
575
  */
258
576
  ilikeAllOf(column: string, patterns: readonly string[]): this {
259
577
  this.url.searchParams.append(column, `ilike(all).{${patterns.join(',')}}`)
@@ -270,6 +588,8 @@ export default class PostgrestFilterBuilder<
270
588
  *
271
589
  * @param column - The column to filter on
272
590
  * @param patterns - The patterns to match with
591
+ *
592
+ * @category Database
273
593
  */
274
594
  ilikeAnyOf(column: string, patterns: readonly string[]): this {
275
595
  this.url.searchParams.append(column, `ilike(any).{${patterns.join(',')}}`)
@@ -320,6 +640,47 @@ export default class PostgrestFilterBuilder<
320
640
  *
321
641
  * @param column - The column to filter on
322
642
  * @param value - The value to filter with
643
+ *
644
+ * @category Database
645
+ *
646
+ * @exampleDescription Checking for nullness, true or false
647
+ * Using the `eq()` filter doesn't work when filtering for `null`.
648
+ *
649
+ * Instead, you need to use `is()`.
650
+ *
651
+ * @example Checking for nullness, true or false
652
+ * ```ts
653
+ * const { data, error } = await supabase
654
+ * .from('countries')
655
+ * .select()
656
+ * .is('name', null)
657
+ * ```
658
+ *
659
+ * @exampleSql Checking for nullness, true or false
660
+ * ```sql
661
+ * create table
662
+ * countries (id int8 primary key, name text);
663
+ *
664
+ * insert into
665
+ * countries (id, name)
666
+ * values
667
+ * (1, 'null'),
668
+ * (2, null);
669
+ * ```
670
+ *
671
+ * @exampleResponse Checking for nullness, true or false
672
+ * ```json
673
+ * {
674
+ * "data": [
675
+ * {
676
+ * "id": 2,
677
+ * "name": "null"
678
+ * }
679
+ * ],
680
+ * "status": 200,
681
+ * "statusText": "OK"
682
+ * }
683
+ * ```
323
684
  */
324
685
  is(column: string, value: boolean | null): this {
325
686
  this.url.searchParams.append(column, `is.${value}`)
@@ -353,6 +714,47 @@ export default class PostgrestFilterBuilder<
353
714
  *
354
715
  * @param column - The column to filter on
355
716
  * @param values - The values array to filter with
717
+ *
718
+ * @category Database
719
+ *
720
+ * @example With `select()`
721
+ * ```ts
722
+ * const { data, error } = await supabase
723
+ * .from('characters')
724
+ * .select()
725
+ * .in('name', ['Leia', 'Han'])
726
+ * ```
727
+ *
728
+ * @exampleSql With `select()`
729
+ * ```sql
730
+ * create table
731
+ * characters (id int8 primary key, name text);
732
+ *
733
+ * insert into
734
+ * characters (id, name)
735
+ * values
736
+ * (1, 'Luke'),
737
+ * (2, 'Leia'),
738
+ * (3, 'Han');
739
+ * ```
740
+ *
741
+ * @exampleResponse With `select()`
742
+ * ```json
743
+ * {
744
+ * "data": [
745
+ * {
746
+ * "id": 2,
747
+ * "name": "Leia"
748
+ * },
749
+ * {
750
+ * "id": 3,
751
+ * "name": "Han"
752
+ * }
753
+ * ],
754
+ * "status": 200,
755
+ * "statusText": "OK"
756
+ * }
757
+ * ```
356
758
  */
357
759
  in<ColumnName extends string>(
358
760
  column: ColumnName,
@@ -418,6 +820,127 @@ export default class PostgrestFilterBuilder<
418
820
  *
419
821
  * @param column - The jsonb, array, or range column to filter on
420
822
  * @param value - The jsonb, array, or range value to filter with
823
+ *
824
+ * @category Database
825
+ *
826
+ * @example On array columns
827
+ * ```ts
828
+ * const { data, error } = await supabase
829
+ * .from('issues')
830
+ * .select()
831
+ * .contains('tags', ['is:open', 'priority:low'])
832
+ * ```
833
+ *
834
+ * @exampleSql On array columns
835
+ * ```sql
836
+ * create table
837
+ * issues (
838
+ * id int8 primary key,
839
+ * title text,
840
+ * tags text[]
841
+ * );
842
+ *
843
+ * insert into
844
+ * issues (id, title, tags)
845
+ * values
846
+ * (1, 'Cache invalidation is not working', array['is:open', 'severity:high', 'priority:low']),
847
+ * (2, 'Use better names', array['is:open', 'severity:low', 'priority:medium']);
848
+ * ```
849
+ *
850
+ * @exampleResponse On array columns
851
+ * ```json
852
+ * {
853
+ * "data": [
854
+ * {
855
+ * "title": "Cache invalidation is not working"
856
+ * }
857
+ * ],
858
+ * "status": 200,
859
+ * "statusText": "OK"
860
+ * }
861
+ * ```
862
+ *
863
+ * @exampleDescription On range columns
864
+ * Postgres supports a number of [range
865
+ * types](https://www.postgresql.org/docs/current/rangetypes.html). You
866
+ * can filter on range columns using the string representation of range
867
+ * values.
868
+ *
869
+ * @example On range columns
870
+ * ```ts
871
+ * const { data, error } = await supabase
872
+ * .from('reservations')
873
+ * .select()
874
+ * .contains('during', '[2000-01-01 13:00, 2000-01-01 13:30)')
875
+ * ```
876
+ *
877
+ * @exampleSql On range columns
878
+ * ```sql
879
+ * create table
880
+ * reservations (
881
+ * id int8 primary key,
882
+ * room_name text,
883
+ * during tsrange
884
+ * );
885
+ *
886
+ * insert into
887
+ * reservations (id, room_name, during)
888
+ * values
889
+ * (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
890
+ * (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
891
+ * ```
892
+ *
893
+ * @exampleResponse On range columns
894
+ * ```json
895
+ * {
896
+ * "data": [
897
+ * {
898
+ * "id": 1,
899
+ * "room_name": "Emerald",
900
+ * "during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
901
+ * }
902
+ * ],
903
+ * "status": 200,
904
+ * "statusText": "OK"
905
+ * }
906
+ * ```
907
+ *
908
+ * @example On `jsonb` columns
909
+ * ```ts
910
+ * const { data, error } = await supabase
911
+ * .from('users')
912
+ * .select('name')
913
+ * .contains('address', { postcode: 90210 })
914
+ * ```
915
+ *
916
+ * @exampleSql On `jsonb` columns
917
+ * ```sql
918
+ * create table
919
+ * users (
920
+ * id int8 primary key,
921
+ * name text,
922
+ * address jsonb
923
+ * );
924
+ *
925
+ * insert into
926
+ * users (id, name, address)
927
+ * values
928
+ * (1, 'Michael', '{ "postcode": 90210, "street": "Melrose Place" }'),
929
+ * (2, 'Jane', '{}');
930
+ * ```
931
+ *
932
+ * @exampleResponse On `jsonb` columns
933
+ * ```json
934
+ * {
935
+ * "data": [
936
+ * {
937
+ * "name": "Michael"
938
+ * }
939
+ * ],
940
+ * "status": 200,
941
+ * "statusText": "OK"
942
+ * }
943
+ * ```
421
944
  */
422
945
  contains(column: string, value: string | readonly unknown[] | Record<string, unknown>): this {
423
946
  if (typeof value === 'string') {
@@ -445,6 +968,128 @@ export default class PostgrestFilterBuilder<
445
968
  *
446
969
  * @param column - The jsonb, array, or range column to filter on
447
970
  * @param value - The jsonb, array, or range value to filter with
971
+ *
972
+ * @category Database
973
+ *
974
+ * @example On array columns
975
+ * ```ts
976
+ * const { data, error } = await supabase
977
+ * .from('classes')
978
+ * .select('name')
979
+ * .containedBy('days', ['monday', 'tuesday', 'wednesday', 'friday'])
980
+ * ```
981
+ *
982
+ * @exampleSql On array columns
983
+ * ```sql
984
+ * create table
985
+ * classes (
986
+ * id int8 primary key,
987
+ * name text,
988
+ * days text[]
989
+ * );
990
+ *
991
+ * insert into
992
+ * classes (id, name, days)
993
+ * values
994
+ * (1, 'Chemistry', array['monday', 'friday']),
995
+ * (2, 'History', array['monday', 'wednesday', 'thursday']);
996
+ * ```
997
+ *
998
+ * @exampleResponse On array columns
999
+ * ```json
1000
+ * {
1001
+ * "data": [
1002
+ * {
1003
+ * "name": "Chemistry"
1004
+ * }
1005
+ * ],
1006
+ * "status": 200,
1007
+ * "statusText": "OK"
1008
+ * }
1009
+ * ```
1010
+ *
1011
+ * @exampleDescription On range columns
1012
+ * Postgres supports a number of [range
1013
+ * types](https://www.postgresql.org/docs/current/rangetypes.html). You
1014
+ * can filter on range columns using the string representation of range
1015
+ * values.
1016
+ *
1017
+ * @example On range columns
1018
+ * ```ts
1019
+ * const { data, error } = await supabase
1020
+ * .from('reservations')
1021
+ * .select()
1022
+ * .containedBy('during', '[2000-01-01 00:00, 2000-01-01 23:59)')
1023
+ * ```
1024
+ *
1025
+ * @exampleSql On range columns
1026
+ * ```sql
1027
+ * create table
1028
+ * reservations (
1029
+ * id int8 primary key,
1030
+ * room_name text,
1031
+ * during tsrange
1032
+ * );
1033
+ *
1034
+ * insert into
1035
+ * reservations (id, room_name, during)
1036
+ * values
1037
+ * (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
1038
+ * (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
1039
+ * ```
1040
+ *
1041
+ * @exampleResponse On range columns
1042
+ * ```json
1043
+ * {
1044
+ * "data": [
1045
+ * {
1046
+ * "id": 1,
1047
+ * "room_name": "Emerald",
1048
+ * "during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
1049
+ * }
1050
+ * ],
1051
+ * "status": 200,
1052
+ * "statusText": "OK"
1053
+ * }
1054
+ * ```
1055
+ *
1056
+ * @example On `jsonb` columns
1057
+ * ```ts
1058
+ * const { data, error } = await supabase
1059
+ * .from('users')
1060
+ * .select('name')
1061
+ * .containedBy('address', {})
1062
+ * ```
1063
+ *
1064
+ * @exampleSql On `jsonb` columns
1065
+ * ```sql
1066
+ * create table
1067
+ * users (
1068
+ * id int8 primary key,
1069
+ * name text,
1070
+ * address jsonb
1071
+ * );
1072
+ *
1073
+ * insert into
1074
+ * users (id, name, address)
1075
+ * values
1076
+ * (1, 'Michael', '{ "postcode": 90210, "street": "Melrose Place" }'),
1077
+ * (2, 'Jane', '{}');
1078
+ * ```
1079
+ *
1080
+ * @exampleResponse On `jsonb` columns
1081
+ * ```json
1082
+ * {
1083
+ * "data": [
1084
+ * {
1085
+ * "name": "Jane"
1086
+ * }
1087
+ * ],
1088
+ * "status": 200,
1089
+ * "statusText": "OK"
1090
+ * }
1091
+ *
1092
+ * ```
448
1093
  */
449
1094
  containedBy(column: string, value: string | readonly unknown[] | Record<string, unknown>): this {
450
1095
  if (typeof value === 'string') {
@@ -468,6 +1113,54 @@ export default class PostgrestFilterBuilder<
468
1113
  *
469
1114
  * @param column - The range column to filter on
470
1115
  * @param range - The range to filter with
1116
+ *
1117
+ * @category Database
1118
+ *
1119
+ * @exampleDescription With `select()`
1120
+ * Postgres supports a number of [range
1121
+ * types](https://www.postgresql.org/docs/current/rangetypes.html). You
1122
+ * can filter on range columns using the string representation of range
1123
+ * values.
1124
+ *
1125
+ * @example With `select()`
1126
+ * ```ts
1127
+ * const { data, error } = await supabase
1128
+ * .from('reservations')
1129
+ * .select()
1130
+ * .rangeGt('during', '[2000-01-02 08:00, 2000-01-02 09:00)')
1131
+ * ```
1132
+ *
1133
+ * @exampleSql With `select()`
1134
+ * ```sql
1135
+ * create table
1136
+ * reservations (
1137
+ * id int8 primary key,
1138
+ * room_name text,
1139
+ * during tsrange
1140
+ * );
1141
+ *
1142
+ * insert into
1143
+ * reservations (id, room_name, during)
1144
+ * values
1145
+ * (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
1146
+ * (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
1147
+ * ```
1148
+ *
1149
+ * @exampleResponse With `select()`
1150
+ * ```json
1151
+ * {
1152
+ * "data": [
1153
+ * {
1154
+ * "id": 2,
1155
+ * "room_name": "Topaz",
1156
+ * "during": "[\"2000-01-02 09:00:00\",\"2000-01-02 10:00:00\")"
1157
+ * }
1158
+ * ],
1159
+ * "status": 200,
1160
+ * "statusText": "OK"
1161
+ * }
1162
+ *
1163
+ * ```
471
1164
  */
472
1165
  rangeGt(column: string, range: string): this {
473
1166
  this.url.searchParams.append(column, `sr.${range}`)
@@ -483,6 +1176,54 @@ export default class PostgrestFilterBuilder<
483
1176
  *
484
1177
  * @param column - The range column to filter on
485
1178
  * @param range - The range to filter with
1179
+ *
1180
+ * @category Database
1181
+ *
1182
+ * @exampleDescription With `select()`
1183
+ * Postgres supports a number of [range
1184
+ * types](https://www.postgresql.org/docs/current/rangetypes.html). You
1185
+ * can filter on range columns using the string representation of range
1186
+ * values.
1187
+ *
1188
+ * @example With `select()`
1189
+ * ```ts
1190
+ * const { data, error } = await supabase
1191
+ * .from('reservations')
1192
+ * .select()
1193
+ * .rangeGte('during', '[2000-01-02 08:30, 2000-01-02 09:30)')
1194
+ * ```
1195
+ *
1196
+ * @exampleSql With `select()`
1197
+ * ```sql
1198
+ * create table
1199
+ * reservations (
1200
+ * id int8 primary key,
1201
+ * room_name text,
1202
+ * during tsrange
1203
+ * );
1204
+ *
1205
+ * insert into
1206
+ * reservations (id, room_name, during)
1207
+ * values
1208
+ * (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
1209
+ * (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
1210
+ * ```
1211
+ *
1212
+ * @exampleResponse With `select()`
1213
+ * ```json
1214
+ * {
1215
+ * "data": [
1216
+ * {
1217
+ * "id": 2,
1218
+ * "room_name": "Topaz",
1219
+ * "during": "[\"2000-01-02 09:00:00\",\"2000-01-02 10:00:00\")"
1220
+ * }
1221
+ * ],
1222
+ * "status": 200,
1223
+ * "statusText": "OK"
1224
+ * }
1225
+ *
1226
+ * ```
486
1227
  */
487
1228
  rangeGte(column: string, range: string): this {
488
1229
  this.url.searchParams.append(column, `nxl.${range}`)
@@ -497,6 +1238,53 @@ export default class PostgrestFilterBuilder<
497
1238
  *
498
1239
  * @param column - The range column to filter on
499
1240
  * @param range - The range to filter with
1241
+ *
1242
+ * @category Database
1243
+ *
1244
+ * @exampleDescription With `select()`
1245
+ * Postgres supports a number of [range
1246
+ * types](https://www.postgresql.org/docs/current/rangetypes.html). You
1247
+ * can filter on range columns using the string representation of range
1248
+ * values.
1249
+ *
1250
+ * @example With `select()`
1251
+ * ```ts
1252
+ * const { data, error } = await supabase
1253
+ * .from('reservations')
1254
+ * .select()
1255
+ * .rangeLt('during', '[2000-01-01 15:00, 2000-01-01 16:00)')
1256
+ * ```
1257
+ *
1258
+ * @exampleSql With `select()`
1259
+ * ```sql
1260
+ * create table
1261
+ * reservations (
1262
+ * id int8 primary key,
1263
+ * room_name text,
1264
+ * during tsrange
1265
+ * );
1266
+ *
1267
+ * insert into
1268
+ * reservations (id, room_name, during)
1269
+ * values
1270
+ * (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
1271
+ * (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
1272
+ * ```
1273
+ *
1274
+ * @exampleResponse With `select()`
1275
+ * ```json
1276
+ * {
1277
+ * "data": [
1278
+ * {
1279
+ * "id": 1,
1280
+ * "room_name": "Emerald",
1281
+ * "during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
1282
+ * }
1283
+ * ],
1284
+ * "status": 200,
1285
+ * "statusText": "OK"
1286
+ * }
1287
+ * ```
500
1288
  */
501
1289
  rangeLt(column: string, range: string): this {
502
1290
  this.url.searchParams.append(column, `sl.${range}`)
@@ -512,6 +1300,54 @@ export default class PostgrestFilterBuilder<
512
1300
  *
513
1301
  * @param column - The range column to filter on
514
1302
  * @param range - The range to filter with
1303
+ *
1304
+ * @category Database
1305
+ *
1306
+ * @exampleDescription With `select()`
1307
+ * Postgres supports a number of [range
1308
+ * types](https://www.postgresql.org/docs/current/rangetypes.html). You
1309
+ * can filter on range columns using the string representation of range
1310
+ * values.
1311
+ *
1312
+ * @example With `select()`
1313
+ * ```ts
1314
+ * const { data, error } = await supabase
1315
+ * .from('reservations')
1316
+ * .select()
1317
+ * .rangeLte('during', '[2000-01-01 14:00, 2000-01-01 16:00)')
1318
+ * ```
1319
+ *
1320
+ * @exampleSql With `select()`
1321
+ * ```sql
1322
+ * create table
1323
+ * reservations (
1324
+ * id int8 primary key,
1325
+ * room_name text,
1326
+ * during tsrange
1327
+ * );
1328
+ *
1329
+ * insert into
1330
+ * reservations (id, room_name, during)
1331
+ * values
1332
+ * (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
1333
+ * (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
1334
+ * ```
1335
+ *
1336
+ * @exampleResponse With `select()`
1337
+ * ```json
1338
+ * {
1339
+ * "data": [
1340
+ * {
1341
+ * "id": 1,
1342
+ * "room_name": "Emerald",
1343
+ * "during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
1344
+ * }
1345
+ * ],
1346
+ * "status": 200,
1347
+ * "statusText": "OK"
1348
+ * }
1349
+ *
1350
+ * ```
515
1351
  */
516
1352
  rangeLte(column: string, range: string): this {
517
1353
  this.url.searchParams.append(column, `nxr.${range}`)
@@ -527,6 +1363,53 @@ export default class PostgrestFilterBuilder<
527
1363
  *
528
1364
  * @param column - The range column to filter on
529
1365
  * @param range - The range to filter with
1366
+ *
1367
+ * @category Database
1368
+ *
1369
+ * @exampleDescription With `select()`
1370
+ * Postgres supports a number of [range
1371
+ * types](https://www.postgresql.org/docs/current/rangetypes.html). You
1372
+ * can filter on range columns using the string representation of range
1373
+ * values.
1374
+ *
1375
+ * @example With `select()`
1376
+ * ```ts
1377
+ * const { data, error } = await supabase
1378
+ * .from('reservations')
1379
+ * .select()
1380
+ * .rangeAdjacent('during', '[2000-01-01 12:00, 2000-01-01 13:00)')
1381
+ * ```
1382
+ *
1383
+ * @exampleSql With `select()`
1384
+ * ```sql
1385
+ * create table
1386
+ * reservations (
1387
+ * id int8 primary key,
1388
+ * room_name text,
1389
+ * during tsrange
1390
+ * );
1391
+ *
1392
+ * insert into
1393
+ * reservations (id, room_name, during)
1394
+ * values
1395
+ * (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
1396
+ * (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
1397
+ * ```
1398
+ *
1399
+ * @exampleResponse With `select()`
1400
+ * ```json
1401
+ * {
1402
+ * "data": [
1403
+ * {
1404
+ * "id": 1,
1405
+ * "room_name": "Emerald",
1406
+ * "during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
1407
+ * }
1408
+ * ],
1409
+ * "status": 200,
1410
+ * "statusText": "OK"
1411
+ * }
1412
+ * ```
530
1413
  */
531
1414
  rangeAdjacent(column: string, range: string): this {
532
1415
  this.url.searchParams.append(column, `adj.${range}`)
@@ -544,6 +1427,90 @@ export default class PostgrestFilterBuilder<
544
1427
  *
545
1428
  * @param column - The array or range column to filter on
546
1429
  * @param value - The array or range value to filter with
1430
+ *
1431
+ * @category Database
1432
+ *
1433
+ * @example On array columns
1434
+ * ```ts
1435
+ * const { data, error } = await supabase
1436
+ * .from('issues')
1437
+ * .select('title')
1438
+ * .overlaps('tags', ['is:closed', 'severity:high'])
1439
+ * ```
1440
+ *
1441
+ * @exampleSql On array columns
1442
+ * ```sql
1443
+ * create table
1444
+ * issues (
1445
+ * id int8 primary key,
1446
+ * title text,
1447
+ * tags text[]
1448
+ * );
1449
+ *
1450
+ * insert into
1451
+ * issues (id, title, tags)
1452
+ * values
1453
+ * (1, 'Cache invalidation is not working', array['is:open', 'severity:high', 'priority:low']),
1454
+ * (2, 'Use better names', array['is:open', 'severity:low', 'priority:medium']);
1455
+ * ```
1456
+ *
1457
+ * @exampleResponse On array columns
1458
+ * ```json
1459
+ * {
1460
+ * "data": [
1461
+ * {
1462
+ * "title": "Cache invalidation is not working"
1463
+ * }
1464
+ * ],
1465
+ * "status": 200,
1466
+ * "statusText": "OK"
1467
+ * }
1468
+ * ```
1469
+ *
1470
+ * @exampleDescription On range columns
1471
+ * Postgres supports a number of [range
1472
+ * types](https://www.postgresql.org/docs/current/rangetypes.html). You
1473
+ * can filter on range columns using the string representation of range
1474
+ * values.
1475
+ *
1476
+ * @example On range columns
1477
+ * ```ts
1478
+ * const { data, error } = await supabase
1479
+ * .from('reservations')
1480
+ * .select()
1481
+ * .overlaps('during', '[2000-01-01 12:45, 2000-01-01 13:15)')
1482
+ * ```
1483
+ *
1484
+ * @exampleSql On range columns
1485
+ * ```sql
1486
+ * create table
1487
+ * reservations (
1488
+ * id int8 primary key,
1489
+ * room_name text,
1490
+ * during tsrange
1491
+ * );
1492
+ *
1493
+ * insert into
1494
+ * reservations (id, room_name, during)
1495
+ * values
1496
+ * (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
1497
+ * (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
1498
+ * ```
1499
+ *
1500
+ * @exampleResponse On range columns
1501
+ * ```json
1502
+ * {
1503
+ * "data": [
1504
+ * {
1505
+ * "id": 1,
1506
+ * "room_name": "Emerald",
1507
+ * "during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
1508
+ * }
1509
+ * ],
1510
+ * "status": 200,
1511
+ * "statusText": "OK"
1512
+ * }
1513
+ * ```
547
1514
  */
548
1515
  overlaps(column: string, value: string | readonly unknown[]): this {
549
1516
  if (typeof value === 'string') {
@@ -575,6 +1542,99 @@ export default class PostgrestFilterBuilder<
575
1542
  * @param options - Named parameters
576
1543
  * @param options.config - The text search configuration to use
577
1544
  * @param options.type - Change how the `query` text is interpreted
1545
+ *
1546
+ * @category Database
1547
+ *
1548
+ * @remarks
1549
+ * - For more information, see [Postgres full text search](/docs/guides/database/full-text-search).
1550
+ *
1551
+ * @example Text search
1552
+ * ```ts
1553
+ * const result = await supabase
1554
+ * .from("texts")
1555
+ * .select("content")
1556
+ * .textSearch("content", `'eggs' & 'ham'`, {
1557
+ * config: "english",
1558
+ * });
1559
+ * ```
1560
+ *
1561
+ * @exampleSql Text search
1562
+ * ```sql
1563
+ * create table texts (
1564
+ * id bigint
1565
+ * primary key
1566
+ * generated always as identity,
1567
+ * content text
1568
+ * );
1569
+ *
1570
+ * insert into texts (content) values
1571
+ * ('Four score and seven years ago'),
1572
+ * ('The road goes ever on and on'),
1573
+ * ('Green eggs and ham')
1574
+ * ;
1575
+ * ```
1576
+ *
1577
+ * @exampleResponse Text search
1578
+ * ```json
1579
+ * {
1580
+ * "data": [
1581
+ * {
1582
+ * "content": "Green eggs and ham"
1583
+ * }
1584
+ * ],
1585
+ * "status": 200,
1586
+ * "statusText": "OK"
1587
+ * }
1588
+ * ```
1589
+ *
1590
+ * @exampleDescription Basic normalization
1591
+ * Uses PostgreSQL's `plainto_tsquery` function.
1592
+ *
1593
+ * @example Basic normalization
1594
+ * ```ts
1595
+ * const { data, error } = await supabase
1596
+ * .from('quotes')
1597
+ * .select('catchphrase')
1598
+ * .textSearch('catchphrase', `'fat' & 'cat'`, {
1599
+ * type: 'plain',
1600
+ * config: 'english'
1601
+ * })
1602
+ * ```
1603
+ *
1604
+ * @exampleDescription Full normalization
1605
+ * Uses PostgreSQL's `phraseto_tsquery` function.
1606
+ *
1607
+ * @example Full normalization
1608
+ * ```ts
1609
+ * const { data, error } = await supabase
1610
+ * .from('quotes')
1611
+ * .select('catchphrase')
1612
+ * .textSearch('catchphrase', `'fat' & 'cat'`, {
1613
+ * type: 'phrase',
1614
+ * config: 'english'
1615
+ * })
1616
+ * ```
1617
+ *
1618
+ * @exampleDescription Websearch
1619
+ * Uses PostgreSQL's `websearch_to_tsquery` function.
1620
+ * This function will never raise syntax errors, which makes it possible to use raw user-supplied input for search, and can be used
1621
+ * with advanced operators.
1622
+ *
1623
+ * - `unquoted text`: text not inside quote marks will be converted to terms separated by & operators, as if processed by plainto_tsquery.
1624
+ * - `"quoted text"`: text inside quote marks will be converted to terms separated by `<->` operators, as if processed by phraseto_tsquery.
1625
+ * - `OR`: the word “or” will be converted to the | operator.
1626
+ * - `-`: a dash will be converted to the ! operator.
1627
+ *
1628
+ * @example Websearch
1629
+ * ```ts
1630
+ * const { data, error } = await supabase
1631
+ * .from('quotes')
1632
+ * .select('catchphrase')
1633
+ * .textSearch('catchphrase', `'fat or cat'`, {
1634
+ * type: 'websearch',
1635
+ * config: 'english'
1636
+ * })
1637
+ * ```
578
1638
  */
579
1639
  textSearch(
580
1640
  column: string,
@@ -602,11 +1662,51 @@ export default class PostgrestFilterBuilder<
602
1662
  *
603
1663
  * @param query - The object to filter with, with column names as keys mapped
604
1664
  * to their filter values
1665
+ *
1666
+ * @category Database
1667
+ *
1668
+ * @example With `select()`
1669
+ * ```ts
1670
+ * const { data, error } = await supabase
1671
+ * .from('characters')
1672
+ * .select('name')
1673
+ * .match({ id: 2, name: 'Leia' })
1674
+ * ```
1675
+ *
1676
+ * @exampleSql With `select()`
1677
+ * ```sql
1678
+ * create table
1679
+ * characters (id int8 primary key, name text);
1680
+ *
1681
+ * insert into
1682
+ * characters (id, name)
1683
+ * values
1684
+ * (1, 'Luke'),
1685
+ * (2, 'Leia'),
1686
+ * (3, 'Han');
1687
+ * ```
1688
+ *
1689
+ * @exampleResponse With `select()`
1690
+ * ```json
1691
+ * {
1692
+ * "data": [
1693
+ * {
1694
+ * "name": "Leia"
1695
+ * }
1696
+ * ],
1697
+ * "status": 200,
1698
+ * "statusText": "OK"
1699
+ * }
1700
+ * ```
605
1701
  */
606
1702
  match(query: Record<string, unknown>): this {
607
- Object.entries(query).forEach(([column, value]) => {
608
- this.url.searchParams.append(column, `eq.${value}`)
609
- })
1703
+ Object.entries(query)
1704
+ // columns with `undefined` value needs to be filtered out, otherwise it'll
1705
+ // show up as `?column=eq.undefined`
1706
+ .filter(([_, value]) => value !== undefined)
1707
+ .forEach(([column, value]) => {
1708
+ this.url.searchParams.append(column, `eq.${value}`)
1709
+ })
610
1710
  return this
611
1711
  }
612
1712
 
@@ -628,6 +1728,51 @@ export default class PostgrestFilterBuilder<
628
1728
  * @param operator - The operator to be negated to filter with, following
629
1729
  * PostgREST syntax
630
1730
  * @param value - The value to filter with, following PostgREST syntax
1731
+ *
1732
+ * @category Database
1733
+ *
1734
+ * @remarks
1735
+ * not() expects you to use the raw PostgREST syntax for the filter values.
1736
+ *
1737
+ * ```ts
1738
+ * .not('id', 'in', '(5,6,7)') // Use `()` for `in` filter
1739
+ * .not('arraycol', 'cs', '{"a","b"}') // Use `cs` for `contains()`, `{}` for array values
1740
+ * ```
1741
+ *
1742
+ * @example With `select()`
1743
+ * ```ts
1744
+ * const { data, error } = await supabase
1745
+ * .from('countries')
1746
+ * .select()
1747
+ * .not('name', 'is', null)
1748
+ * ```
1749
+ *
1750
+ * @exampleSql With `select()`
1751
+ * ```sql
1752
+ * create table
1753
+ * countries (id int8 primary key, name text);
1754
+ *
1755
+ * insert into
1756
+ * countries (id, name)
1757
+ * values
1758
+ * (1, 'null'),
1759
+ * (2, null);
1760
+ * ```
1761
+ *
1762
+ * @exampleResponse With `select()`
1763
+ * ```json
1764
+ * {
1765
+ * "data": [
1766
+ * {
1767
+ * "id": 1,
1768
+ * "name": "null"
1769
+ * }
1770
+ * ],
1771
+ * "status": 200,
1772
+ * "statusText": "OK"
1773
+ * }
1774
+ *
1775
+ * ```
631
1776
  */
632
1777
  not(column: string, operator: string, value: unknown): this {
633
1778
  this.url.searchParams.append(column, `not.${operator}.${value}`)
@@ -648,6 +1793,141 @@ export default class PostgrestFilterBuilder<
648
1793
  * @param options.referencedTable - Set this to filter on referenced tables
649
1794
  * instead of the parent table
650
1795
  * @param options.foreignTable - Deprecated, use `referencedTable` instead
1796
+ *
1797
+ * @category Database
1798
+ *
1799
+ * @remarks
1800
+ * or() expects you to use the raw PostgREST syntax for the filter names and values.
1801
+ *
1802
+ * ```ts
1803
+ * .or('id.in.(5,6,7), arraycol.cs.{"a","b"}') // Use `()` for `in` filter, `{}` for array values and `cs` for `contains()`.
1804
+ * .or('id.in.(5,6,7), arraycol.cd.{"a","b"}') // Use `cd` for `containedBy()`
1805
+ * ```
1806
+ *
1807
+ * @example With `select()`
1808
+ * ```ts
1809
+ * const { data, error } = await supabase
1810
+ * .from('characters')
1811
+ * .select('name')
1812
+ * .or('id.eq.2,name.eq.Han')
1813
+ * ```
1814
+ *
1815
+ * @exampleSql With `select()`
1816
+ * ```sql
1817
+ * create table
1818
+ * characters (id int8 primary key, name text);
1819
+ *
1820
+ * insert into
1821
+ * characters (id, name)
1822
+ * values
1823
+ * (1, 'Luke'),
1824
+ * (2, 'Leia'),
1825
+ * (3, 'Han');
1826
+ * ```
1827
+ *
1828
+ * @exampleResponse With `select()`
1829
+ * ```json
1830
+ * {
1831
+ * "data": [
1832
+ * {
1833
+ * "name": "Leia"
1834
+ * },
1835
+ * {
1836
+ * "name": "Han"
1837
+ * }
1838
+ * ],
1839
+ * "status": 200,
1840
+ * "statusText": "OK"
1841
+ * }
1842
+ * ```
1843
+ *
1844
+ * @example Use `or` with `and`
1845
+ * ```ts
1846
+ * const { data, error } = await supabase
1847
+ * .from('characters')
1848
+ * .select('name')
1849
+ * .or('id.gt.3,and(id.eq.1,name.eq.Luke)')
1850
+ * ```
1851
+ *
1852
+ * @exampleSql Use `or` with `and`
1853
+ * ```sql
1854
+ * create table
1855
+ * characters (id int8 primary key, name text);
1856
+ *
1857
+ * insert into
1858
+ * characters (id, name)
1859
+ * values
1860
+ * (1, 'Luke'),
1861
+ * (2, 'Leia'),
1862
+ * (3, 'Han');
1863
+ * ```
1864
+ *
1865
+ * @exampleResponse Use `or` with `and`
1866
+ * ```json
1867
+ * {
1868
+ * "data": [
1869
+ * {
1870
+ * "name": "Luke"
1871
+ * }
1872
+ * ],
1873
+ * "status": 200,
1874
+ * "statusText": "OK"
1875
+ * }
1876
+ * ```
1877
+ *
1878
+ * @example Use `or` on referenced tables
1879
+ * ```ts
1880
+ * const { data, error } = await supabase
1881
+ * .from('orchestral_sections')
1882
+ * .select(`
1883
+ * name,
1884
+ * instruments!inner (
1885
+ * name
1886
+ * )
1887
+ * `)
1888
+ * .or('section_id.eq.1,name.eq.guzheng', { referencedTable: 'instruments' })
1889
+ * ```
1890
+ *
1891
+ * @exampleSql Use `or` on referenced tables
1892
+ * ```sql
1893
+ * create table
1894
+ * orchestral_sections (id int8 primary key, name text);
1895
+ * create table
1896
+ * instruments (
1897
+ * id int8 primary key,
1898
+ * section_id int8 not null references orchestral_sections,
1899
+ * name text
1900
+ * );
1901
+ *
1902
+ * insert into
1903
+ * orchestral_sections (id, name)
1904
+ * values
1905
+ * (1, 'strings'),
1906
+ * (2, 'woodwinds');
1907
+ * insert into
1908
+ * instruments (id, section_id, name)
1909
+ * values
1910
+ * (1, 2, 'flute'),
1911
+ * (2, 1, 'violin');
1912
+ * ```
1913
+ *
1914
+ * @exampleResponse Use `or` on referenced tables
1915
+ * ```json
1916
+ * {
1917
+ * "data": [
1918
+ * {
1919
+ * "name": "strings",
1920
+ * "instruments": [
1921
+ * {
1922
+ * "name": "violin"
1923
+ * }
1924
+ * ]
1925
+ * }
1926
+ * ],
1927
+ * "status": 200,
1928
+ * "statusText": "OK"
1929
+ * }
1930
+ * ```
651
1931
  */
652
1932
  or(
653
1933
  filters: string,
@@ -679,6 +1959,105 @@ export default class PostgrestFilterBuilder<
679
1959
  * @param column - The column to filter on
680
1960
  * @param operator - The operator to filter with, following PostgREST syntax
681
1961
  * @param value - The value to filter with, following PostgREST syntax
1962
+ *
1963
+ * @category Database
1964
+ *
1965
+ * @remarks
1966
+ * filter() expects you to use the raw PostgREST syntax for the filter values.
1967
+ *
1968
+ * ```ts
1969
+ * .filter('id', 'in', '(5,6,7)') // Use `()` for `in` filter
1970
+ * .filter('arraycol', 'cs', '{"a","b"}') // Use `cs` for `contains()`, `{}` for array values
1971
+ * ```
1972
+ *
1973
+ * @example With `select()`
1974
+ * ```ts
1975
+ * const { data, error } = await supabase
1976
+ * .from('characters')
1977
+ * .select()
1978
+ * .filter('name', 'in', '("Han","Yoda")')
1979
+ * ```
1980
+ *
1981
+ * @exampleSql With `select()`
1982
+ * ```sql
1983
+ * create table
1984
+ * characters (id int8 primary key, name text);
1985
+ *
1986
+ * insert into
1987
+ * characters (id, name)
1988
+ * values
1989
+ * (1, 'Luke'),
1990
+ * (2, 'Leia'),
1991
+ * (3, 'Han');
1992
+ * ```
1993
+ *
1994
+ * @exampleResponse With `select()`
1995
+ * ```json
1996
+ * {
1997
+ * "data": [
1998
+ * {
1999
+ * "id": 3,
2000
+ * "name": "Han"
2001
+ * }
2002
+ * ],
2003
+ * "status": 200,
2004
+ * "statusText": "OK"
2005
+ * }
2006
+ * ```
2007
+ *
2008
+ * @example On a referenced table
2009
+ * ```ts
2010
+ * const { data, error } = await supabase
2011
+ * .from('orchestral_sections')
2012
+ * .select(`
2013
+ * name,
2014
+ * instruments!inner (
2015
+ * name
2016
+ * )
2017
+ * `)
2018
+ * .filter('instruments.name', 'eq', 'flute')
2019
+ * ```
2020
+ *
2021
+ * @exampleSql On a referenced table
2022
+ * ```sql
2023
+ * create table
2024
+ * orchestral_sections (id int8 primary key, name text);
2025
+ * create table
2026
+ * instruments (
2027
+ * id int8 primary key,
2028
+ * section_id int8 not null references orchestral_sections,
2029
+ * name text
2030
+ * );
2031
+ *
2032
+ * insert into
2033
+ * orchestral_sections (id, name)
2034
+ * values
2035
+ * (1, 'strings'),
2036
+ * (2, 'woodwinds');
2037
+ * insert into
2038
+ * instruments (id, section_id, name)
2039
+ * values
2040
+ * (1, 2, 'flute'),
2041
+ * (2, 1, 'violin');
2042
+ * ```
2043
+ *
2044
+ * @exampleResponse On a referenced table
2045
+ * ```json
2046
+ * {
2047
+ * "data": [
2048
+ * {
2049
+ * "name": "woodwinds",
2050
+ * "instruments": [
2051
+ * {
2052
+ * "name": "flute"
2053
+ * }
2054
+ * ]
2055
+ * }
2056
+ * ],
2057
+ * "status": 200,
2058
+ * "statusText": "OK"
2059
+ * }
2060
+ * ```
682
2061
  */
683
2062
  filter(column: string, operator: string, value: unknown): this {
684
2063
  this.url.searchParams.append(column, `${operator}.${value}`)