@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.cjs +2475 -130
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1055 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1055 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2475 -130
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/PostgrestBuilder.ts +93 -1
- package/src/PostgrestClient.ts +165 -1
- package/src/PostgrestFilterBuilder.ts +1382 -3
- package/src/PostgrestQueryBuilder.ts +112 -1
- package/src/PostgrestTransformBuilder.ts +603 -0
- package/src/version.ts +1 -1
|
@@ -22,6 +22,41 @@ export default class PostgrestTransformBuilder<
|
|
|
22
22
|
* `data`.
|
|
23
23
|
*
|
|
24
24
|
* @param columns - The columns to retrieve, separated by commas
|
|
25
|
+
*
|
|
26
|
+
* @category Database
|
|
27
|
+
*
|
|
28
|
+
* @example With `upsert()`
|
|
29
|
+
* ```ts
|
|
30
|
+
* const { data, error } = await supabase
|
|
31
|
+
* .from('characters')
|
|
32
|
+
* .upsert({ id: 1, name: 'Han Solo' })
|
|
33
|
+
* .select()
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @exampleSql With `upsert()`
|
|
37
|
+
* ```sql
|
|
38
|
+
* create table
|
|
39
|
+
* characters (id int8 primary key, name text);
|
|
40
|
+
*
|
|
41
|
+
* insert into
|
|
42
|
+
* characters (id, name)
|
|
43
|
+
* values
|
|
44
|
+
* (1, 'Han');
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @exampleResponse With `upsert()`
|
|
48
|
+
* ```json
|
|
49
|
+
* {
|
|
50
|
+
* "data": [
|
|
51
|
+
* {
|
|
52
|
+
* "id": 1,
|
|
53
|
+
* "name": "Han Solo"
|
|
54
|
+
* }
|
|
55
|
+
* ],
|
|
56
|
+
* "status": 201,
|
|
57
|
+
* "statusText": "Created"
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
25
60
|
*/
|
|
26
61
|
select<
|
|
27
62
|
Query extends string = '*',
|
|
@@ -111,6 +146,176 @@ export default class PostgrestTransformBuilder<
|
|
|
111
146
|
* its columns
|
|
112
147
|
* @param options.foreignTable - Deprecated, use `options.referencedTable`
|
|
113
148
|
* instead
|
|
149
|
+
*
|
|
150
|
+
* @category Database
|
|
151
|
+
*
|
|
152
|
+
* @example With `select()`
|
|
153
|
+
* ```ts
|
|
154
|
+
* const { data, error } = await supabase
|
|
155
|
+
* .from('characters')
|
|
156
|
+
* .select('id, name')
|
|
157
|
+
* .order('id', { ascending: false })
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* @exampleSql With `select()`
|
|
161
|
+
* ```sql
|
|
162
|
+
* create table
|
|
163
|
+
* characters (id int8 primary key, name text);
|
|
164
|
+
*
|
|
165
|
+
* insert into
|
|
166
|
+
* characters (id, name)
|
|
167
|
+
* values
|
|
168
|
+
* (1, 'Luke'),
|
|
169
|
+
* (2, 'Leia'),
|
|
170
|
+
* (3, 'Han');
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* @exampleResponse With `select()`
|
|
174
|
+
* ```json
|
|
175
|
+
* {
|
|
176
|
+
* "data": [
|
|
177
|
+
* {
|
|
178
|
+
* "id": 3,
|
|
179
|
+
* "name": "Han"
|
|
180
|
+
* },
|
|
181
|
+
* {
|
|
182
|
+
* "id": 2,
|
|
183
|
+
* "name": "Leia"
|
|
184
|
+
* },
|
|
185
|
+
* {
|
|
186
|
+
* "id": 1,
|
|
187
|
+
* "name": "Luke"
|
|
188
|
+
* }
|
|
189
|
+
* ],
|
|
190
|
+
* "status": 200,
|
|
191
|
+
* "statusText": "OK"
|
|
192
|
+
* }
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* @exampleDescription On a referenced table
|
|
196
|
+
* Ordering with `referencedTable` doesn't affect the ordering of the
|
|
197
|
+
* parent table.
|
|
198
|
+
*
|
|
199
|
+
* @example On a referenced table
|
|
200
|
+
* ```ts
|
|
201
|
+
* const { data, error } = await supabase
|
|
202
|
+
* .from('orchestral_sections')
|
|
203
|
+
* .select(`
|
|
204
|
+
* name,
|
|
205
|
+
* instruments (
|
|
206
|
+
* name
|
|
207
|
+
* )
|
|
208
|
+
* `)
|
|
209
|
+
* .order('name', { referencedTable: 'instruments', ascending: false })
|
|
210
|
+
*
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
213
|
+
* @exampleSql On a referenced table
|
|
214
|
+
* ```sql
|
|
215
|
+
* create table
|
|
216
|
+
* orchestral_sections (id int8 primary key, name text);
|
|
217
|
+
* create table
|
|
218
|
+
* instruments (
|
|
219
|
+
* id int8 primary key,
|
|
220
|
+
* section_id int8 not null references orchestral_sections,
|
|
221
|
+
* name text
|
|
222
|
+
* );
|
|
223
|
+
*
|
|
224
|
+
* insert into
|
|
225
|
+
* orchestral_sections (id, name)
|
|
226
|
+
* values
|
|
227
|
+
* (1, 'strings'),
|
|
228
|
+
* (2, 'woodwinds');
|
|
229
|
+
* insert into
|
|
230
|
+
* instruments (id, section_id, name)
|
|
231
|
+
* values
|
|
232
|
+
* (1, 1, 'harp'),
|
|
233
|
+
* (2, 1, 'violin');
|
|
234
|
+
* ```
|
|
235
|
+
*
|
|
236
|
+
* @exampleResponse On a referenced table
|
|
237
|
+
* ```json
|
|
238
|
+
* {
|
|
239
|
+
* "data": [
|
|
240
|
+
* {
|
|
241
|
+
* "name": "strings",
|
|
242
|
+
* "instruments": [
|
|
243
|
+
* {
|
|
244
|
+
* "name": "violin"
|
|
245
|
+
* },
|
|
246
|
+
* {
|
|
247
|
+
* "name": "harp"
|
|
248
|
+
* }
|
|
249
|
+
* ]
|
|
250
|
+
* },
|
|
251
|
+
* {
|
|
252
|
+
* "name": "woodwinds",
|
|
253
|
+
* "instruments": []
|
|
254
|
+
* }
|
|
255
|
+
* ],
|
|
256
|
+
* "status": 200,
|
|
257
|
+
* "statusText": "OK"
|
|
258
|
+
* }
|
|
259
|
+
* ```
|
|
260
|
+
*
|
|
261
|
+
* @exampleDescription Order parent table by a referenced table
|
|
262
|
+
* Ordering with `referenced_table(col)` affects the ordering of the
|
|
263
|
+
* parent table.
|
|
264
|
+
*
|
|
265
|
+
* @example Order parent table by a referenced table
|
|
266
|
+
* ```ts
|
|
267
|
+
* const { data, error } = await supabase
|
|
268
|
+
* .from('instruments')
|
|
269
|
+
* .select(`
|
|
270
|
+
* name,
|
|
271
|
+
* section:orchestral_sections (
|
|
272
|
+
* name
|
|
273
|
+
* )
|
|
274
|
+
* `)
|
|
275
|
+
* .order('section(name)', { ascending: true })
|
|
276
|
+
*
|
|
277
|
+
* ```
|
|
278
|
+
*
|
|
279
|
+
* @exampleSql Order parent table by a referenced table
|
|
280
|
+
* ```sql
|
|
281
|
+
* create table
|
|
282
|
+
* orchestral_sections (id int8 primary key, name text);
|
|
283
|
+
* create table
|
|
284
|
+
* instruments (
|
|
285
|
+
* id int8 primary key,
|
|
286
|
+
* section_id int8 not null references orchestral_sections,
|
|
287
|
+
* name text
|
|
288
|
+
* );
|
|
289
|
+
*
|
|
290
|
+
* insert into
|
|
291
|
+
* orchestral_sections (id, name)
|
|
292
|
+
* values
|
|
293
|
+
* (1, 'strings'),
|
|
294
|
+
* (2, 'woodwinds');
|
|
295
|
+
* insert into
|
|
296
|
+
* instruments (id, section_id, name)
|
|
297
|
+
* values
|
|
298
|
+
* (1, 2, 'flute'),
|
|
299
|
+
* (2, 1, 'violin');
|
|
300
|
+
* ```
|
|
301
|
+
*
|
|
302
|
+
* @exampleResponse Order parent table by a referenced table
|
|
303
|
+
* ```json
|
|
304
|
+
* {
|
|
305
|
+
* "data": [
|
|
306
|
+
* {
|
|
307
|
+
* "name": "violin",
|
|
308
|
+
* "orchestral_sections": {"name": "strings"}
|
|
309
|
+
* },
|
|
310
|
+
* {
|
|
311
|
+
* "name": "flute",
|
|
312
|
+
* "orchestral_sections": {"name": "woodwinds"}
|
|
313
|
+
* }
|
|
314
|
+
* ],
|
|
315
|
+
* "status": 200,
|
|
316
|
+
* "statusText": "OK"
|
|
317
|
+
* }
|
|
318
|
+
* ```
|
|
114
319
|
*/
|
|
115
320
|
order(
|
|
116
321
|
column: string,
|
|
@@ -147,6 +352,95 @@ export default class PostgrestTransformBuilder<
|
|
|
147
352
|
* tables instead of the parent table
|
|
148
353
|
* @param options.foreignTable - Deprecated, use `options.referencedTable`
|
|
149
354
|
* instead
|
|
355
|
+
*
|
|
356
|
+
* @category Database
|
|
357
|
+
*
|
|
358
|
+
* @example With `select()`
|
|
359
|
+
* ```ts
|
|
360
|
+
* const { data, error } = await supabase
|
|
361
|
+
* .from('characters')
|
|
362
|
+
* .select('name')
|
|
363
|
+
* .limit(1)
|
|
364
|
+
* ```
|
|
365
|
+
*
|
|
366
|
+
* @exampleSql With `select()`
|
|
367
|
+
* ```sql
|
|
368
|
+
* create table
|
|
369
|
+
* characters (id int8 primary key, name text);
|
|
370
|
+
*
|
|
371
|
+
* insert into
|
|
372
|
+
* characters (id, name)
|
|
373
|
+
* values
|
|
374
|
+
* (1, 'Luke'),
|
|
375
|
+
* (2, 'Leia'),
|
|
376
|
+
* (3, 'Han');
|
|
377
|
+
* ```
|
|
378
|
+
*
|
|
379
|
+
* @exampleResponse With `select()`
|
|
380
|
+
* ```json
|
|
381
|
+
* {
|
|
382
|
+
* "data": [
|
|
383
|
+
* {
|
|
384
|
+
* "name": "Luke"
|
|
385
|
+
* }
|
|
386
|
+
* ],
|
|
387
|
+
* "status": 200,
|
|
388
|
+
* "statusText": "OK"
|
|
389
|
+
* }
|
|
390
|
+
* ```
|
|
391
|
+
*
|
|
392
|
+
* @example On a referenced table
|
|
393
|
+
* ```ts
|
|
394
|
+
* const { data, error } = await supabase
|
|
395
|
+
* .from('orchestral_sections')
|
|
396
|
+
* .select(`
|
|
397
|
+
* name,
|
|
398
|
+
* instruments (
|
|
399
|
+
* name
|
|
400
|
+
* )
|
|
401
|
+
* `)
|
|
402
|
+
* .limit(1, { referencedTable: 'instruments' })
|
|
403
|
+
* ```
|
|
404
|
+
*
|
|
405
|
+
* @exampleSql On a referenced table
|
|
406
|
+
* ```sql
|
|
407
|
+
* create table
|
|
408
|
+
* orchestral_sections (id int8 primary key, name text);
|
|
409
|
+
* create table
|
|
410
|
+
* instruments (
|
|
411
|
+
* id int8 primary key,
|
|
412
|
+
* section_id int8 not null references orchestral_sections,
|
|
413
|
+
* name text
|
|
414
|
+
* );
|
|
415
|
+
*
|
|
416
|
+
* insert into
|
|
417
|
+
* orchestral_sections (id, name)
|
|
418
|
+
* values
|
|
419
|
+
* (1, 'strings');
|
|
420
|
+
* insert into
|
|
421
|
+
* instruments (id, section_id, name)
|
|
422
|
+
* values
|
|
423
|
+
* (1, 1, 'harp'),
|
|
424
|
+
* (2, 1, 'violin');
|
|
425
|
+
* ```
|
|
426
|
+
*
|
|
427
|
+
* @exampleResponse On a referenced table
|
|
428
|
+
* ```json
|
|
429
|
+
* {
|
|
430
|
+
* "data": [
|
|
431
|
+
* {
|
|
432
|
+
* "name": "strings",
|
|
433
|
+
* "instruments": [
|
|
434
|
+
* {
|
|
435
|
+
* "name": "violin"
|
|
436
|
+
* }
|
|
437
|
+
* ]
|
|
438
|
+
* }
|
|
439
|
+
* ],
|
|
440
|
+
* "status": 200,
|
|
441
|
+
* "statusText": "OK"
|
|
442
|
+
* }
|
|
443
|
+
* ```
|
|
150
444
|
*/
|
|
151
445
|
limit(
|
|
152
446
|
count: number,
|
|
@@ -174,6 +468,45 @@ export default class PostgrestTransformBuilder<
|
|
|
174
468
|
* tables instead of the parent table
|
|
175
469
|
* @param options.foreignTable - Deprecated, use `options.referencedTable`
|
|
176
470
|
* instead
|
|
471
|
+
*
|
|
472
|
+
* @category Database
|
|
473
|
+
*
|
|
474
|
+
* @example With `select()`
|
|
475
|
+
* ```ts
|
|
476
|
+
* const { data, error } = await supabase
|
|
477
|
+
* .from('characters')
|
|
478
|
+
* .select('name')
|
|
479
|
+
* .range(0, 1)
|
|
480
|
+
* ```
|
|
481
|
+
*
|
|
482
|
+
* @exampleSql With `select()`
|
|
483
|
+
* ```sql
|
|
484
|
+
* create table
|
|
485
|
+
* characters (id int8 primary key, name text);
|
|
486
|
+
*
|
|
487
|
+
* insert into
|
|
488
|
+
* characters (id, name)
|
|
489
|
+
* values
|
|
490
|
+
* (1, 'Luke'),
|
|
491
|
+
* (2, 'Leia'),
|
|
492
|
+
* (3, 'Han');
|
|
493
|
+
* ```
|
|
494
|
+
*
|
|
495
|
+
* @exampleResponse With `select()`
|
|
496
|
+
* ```json
|
|
497
|
+
* {
|
|
498
|
+
* "data": [
|
|
499
|
+
* {
|
|
500
|
+
* "name": "Luke"
|
|
501
|
+
* },
|
|
502
|
+
* {
|
|
503
|
+
* "name": "Leia"
|
|
504
|
+
* }
|
|
505
|
+
* ],
|
|
506
|
+
* "status": 200,
|
|
507
|
+
* "statusText": "OK"
|
|
508
|
+
* }
|
|
509
|
+
* ```
|
|
177
510
|
*/
|
|
178
511
|
range(
|
|
179
512
|
from: number,
|
|
@@ -196,6 +529,66 @@ export default class PostgrestTransformBuilder<
|
|
|
196
529
|
* Set the AbortSignal for the fetch request.
|
|
197
530
|
*
|
|
198
531
|
* @param signal - The AbortSignal to use for the fetch request
|
|
532
|
+
*
|
|
533
|
+
* @category Database
|
|
534
|
+
*
|
|
535
|
+
* @remarks
|
|
536
|
+
* You can use this to set a timeout for the request.
|
|
537
|
+
*
|
|
538
|
+
* @exampleDescription Aborting requests in-flight
|
|
539
|
+
* You can use an [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) to abort requests.
|
|
540
|
+
* Note that `status` and `statusText` don't mean anything for aborted requests as the request wasn't fulfilled.
|
|
541
|
+
*
|
|
542
|
+
* @example Aborting requests in-flight
|
|
543
|
+
* ```ts
|
|
544
|
+
* const ac = new AbortController()
|
|
545
|
+
*
|
|
546
|
+
* const { data, error } = await supabase
|
|
547
|
+
* .from('very_big_table')
|
|
548
|
+
* .select()
|
|
549
|
+
* .abortSignal(ac.signal)
|
|
550
|
+
*
|
|
551
|
+
* // Abort the request after 100 ms
|
|
552
|
+
* setTimeout(() => ac.abort(), 100)
|
|
553
|
+
* ```
|
|
554
|
+
*
|
|
555
|
+
* @exampleResponse Aborting requests in-flight
|
|
556
|
+
* ```json
|
|
557
|
+
* {
|
|
558
|
+
* "error": {
|
|
559
|
+
* "message": "AbortError: The user aborted a request.",
|
|
560
|
+
* "details": "",
|
|
561
|
+
* "hint": "The request was aborted locally via the provided AbortSignal.",
|
|
562
|
+
* "code": ""
|
|
563
|
+
* },
|
|
564
|
+
* "status": 0,
|
|
565
|
+
* "statusText": ""
|
|
566
|
+
* }
|
|
567
|
+
*
|
|
568
|
+
* ```
|
|
569
|
+
*
|
|
570
|
+
* @example Set a timeout
|
|
571
|
+
* ```ts
|
|
572
|
+
* const { data, error } = await supabase
|
|
573
|
+
* .from('very_big_table')
|
|
574
|
+
* .select()
|
|
575
|
+
* .abortSignal(AbortSignal.timeout(1000 /* ms *\/))
|
|
576
|
+
* ```
|
|
577
|
+
*
|
|
578
|
+
* @exampleResponse Set a timeout
|
|
579
|
+
* ```json
|
|
580
|
+
* {
|
|
581
|
+
* "error": {
|
|
582
|
+
* "message": "FetchError: The user aborted a request.",
|
|
583
|
+
* "details": "",
|
|
584
|
+
* "hint": "",
|
|
585
|
+
* "code": ""
|
|
586
|
+
* },
|
|
587
|
+
* "status": 400,
|
|
588
|
+
* "statusText": "Bad Request"
|
|
589
|
+
* }
|
|
590
|
+
*
|
|
591
|
+
* ```
|
|
199
592
|
*/
|
|
200
593
|
abortSignal(signal: AbortSignal): this {
|
|
201
594
|
this.signal = signal
|
|
@@ -207,6 +600,41 @@ export default class PostgrestTransformBuilder<
|
|
|
207
600
|
*
|
|
208
601
|
* Query result must be one row (e.g. using `.limit(1)`), otherwise this
|
|
209
602
|
* returns an error.
|
|
603
|
+
*
|
|
604
|
+
* @category Database
|
|
605
|
+
*
|
|
606
|
+
* @example With `select()`
|
|
607
|
+
* ```ts
|
|
608
|
+
* const { data, error } = await supabase
|
|
609
|
+
* .from('characters')
|
|
610
|
+
* .select('name')
|
|
611
|
+
* .limit(1)
|
|
612
|
+
* .single()
|
|
613
|
+
* ```
|
|
614
|
+
*
|
|
615
|
+
* @exampleSql With `select()`
|
|
616
|
+
* ```sql
|
|
617
|
+
* create table
|
|
618
|
+
* characters (id int8 primary key, name text);
|
|
619
|
+
*
|
|
620
|
+
* insert into
|
|
621
|
+
* characters (id, name)
|
|
622
|
+
* values
|
|
623
|
+
* (1, 'Luke'),
|
|
624
|
+
* (2, 'Leia'),
|
|
625
|
+
* (3, 'Han');
|
|
626
|
+
* ```
|
|
627
|
+
*
|
|
628
|
+
* @exampleResponse With `select()`
|
|
629
|
+
* ```json
|
|
630
|
+
* {
|
|
631
|
+
* "data": {
|
|
632
|
+
* "name": "Luke"
|
|
633
|
+
* },
|
|
634
|
+
* "status": 200,
|
|
635
|
+
* "statusText": "OK"
|
|
636
|
+
* }
|
|
637
|
+
* ```
|
|
210
638
|
*/
|
|
211
639
|
single<ResultOne = Result extends (infer ResultOne)[] ? ResultOne : never>(): PostgrestBuilder<
|
|
212
640
|
ClientOptions,
|
|
@@ -221,6 +649,38 @@ export default class PostgrestTransformBuilder<
|
|
|
221
649
|
*
|
|
222
650
|
* Query result must be zero or one row (e.g. using `.limit(1)`), otherwise
|
|
223
651
|
* this returns an error.
|
|
652
|
+
*
|
|
653
|
+
* @category Database
|
|
654
|
+
*
|
|
655
|
+
* @example With `select()`
|
|
656
|
+
* ```ts
|
|
657
|
+
* const { data, error } = await supabase
|
|
658
|
+
* .from('characters')
|
|
659
|
+
* .select()
|
|
660
|
+
* .eq('name', 'Katniss')
|
|
661
|
+
* .maybeSingle()
|
|
662
|
+
* ```
|
|
663
|
+
*
|
|
664
|
+
* @exampleSql With `select()`
|
|
665
|
+
* ```sql
|
|
666
|
+
* create table
|
|
667
|
+
* characters (id int8 primary key, name text);
|
|
668
|
+
*
|
|
669
|
+
* insert into
|
|
670
|
+
* characters (id, name)
|
|
671
|
+
* values
|
|
672
|
+
* (1, 'Luke'),
|
|
673
|
+
* (2, 'Leia'),
|
|
674
|
+
* (3, 'Han');
|
|
675
|
+
* ```
|
|
676
|
+
*
|
|
677
|
+
* @exampleResponse With `select()`
|
|
678
|
+
* ```json
|
|
679
|
+
* {
|
|
680
|
+
* "status": 200,
|
|
681
|
+
* "statusText": "OK"
|
|
682
|
+
* }
|
|
683
|
+
* ```
|
|
224
684
|
*/
|
|
225
685
|
maybeSingle<
|
|
226
686
|
ResultOne = Result extends (infer ResultOne)[] ? ResultOne : never,
|
|
@@ -238,6 +698,41 @@ export default class PostgrestTransformBuilder<
|
|
|
238
698
|
|
|
239
699
|
/**
|
|
240
700
|
* Return `data` as a string in CSV format.
|
|
701
|
+
*
|
|
702
|
+
* @category Database
|
|
703
|
+
*
|
|
704
|
+
* @exampleDescription Return data as CSV
|
|
705
|
+
* By default, the data is returned in JSON format, but can also be returned as Comma Separated Values.
|
|
706
|
+
*
|
|
707
|
+
* @example Return data as CSV
|
|
708
|
+
* ```ts
|
|
709
|
+
* const { data, error } = await supabase
|
|
710
|
+
* .from('characters')
|
|
711
|
+
* .select()
|
|
712
|
+
* .csv()
|
|
713
|
+
* ```
|
|
714
|
+
*
|
|
715
|
+
* @exampleSql Return data as CSV
|
|
716
|
+
* ```sql
|
|
717
|
+
* create table
|
|
718
|
+
* characters (id int8 primary key, name text);
|
|
719
|
+
*
|
|
720
|
+
* insert into
|
|
721
|
+
* characters (id, name)
|
|
722
|
+
* values
|
|
723
|
+
* (1, 'Luke'),
|
|
724
|
+
* (2, 'Leia'),
|
|
725
|
+
* (3, 'Han');
|
|
726
|
+
* ```
|
|
727
|
+
*
|
|
728
|
+
* @exampleResponse Return data as CSV
|
|
729
|
+
* ```json
|
|
730
|
+
* {
|
|
731
|
+
* "data": "id,name\n1,Luke\n2,Leia\n3,Han",
|
|
732
|
+
* "status": 200,
|
|
733
|
+
* "statusText": "OK"
|
|
734
|
+
* }
|
|
735
|
+
* ```
|
|
241
736
|
*/
|
|
242
737
|
csv(): PostgrestBuilder<ClientOptions, string> {
|
|
243
738
|
this.headers.set('Accept', 'text/csv')
|
|
@@ -246,6 +741,8 @@ export default class PostgrestTransformBuilder<
|
|
|
246
741
|
|
|
247
742
|
/**
|
|
248
743
|
* Return `data` as an object in [GeoJSON](https://geojson.org) format.
|
|
744
|
+
*
|
|
745
|
+
* @category Database
|
|
249
746
|
*/
|
|
250
747
|
geojson(): PostgrestBuilder<ClientOptions, Record<string, unknown>> {
|
|
251
748
|
this.headers.set('Accept', 'application/geo+json')
|
|
@@ -276,6 +773,76 @@ export default class PostgrestTransformBuilder<
|
|
|
276
773
|
*
|
|
277
774
|
* @param options.format - The format of the output, can be `"text"` (default)
|
|
278
775
|
* or `"json"`
|
|
776
|
+
*
|
|
777
|
+
* @category Database
|
|
778
|
+
*
|
|
779
|
+
* @exampleDescription Get the execution plan
|
|
780
|
+
* By default, the data is returned in TEXT format, but can also be returned as JSON by using the `format` parameter.
|
|
781
|
+
*
|
|
782
|
+
* @example Get the execution plan
|
|
783
|
+
* ```ts
|
|
784
|
+
* const { data, error } = await supabase
|
|
785
|
+
* .from('characters')
|
|
786
|
+
* .select()
|
|
787
|
+
* .explain()
|
|
788
|
+
* ```
|
|
789
|
+
*
|
|
790
|
+
* @exampleSql Get the execution plan
|
|
791
|
+
* ```sql
|
|
792
|
+
* create table
|
|
793
|
+
* characters (id int8 primary key, name text);
|
|
794
|
+
*
|
|
795
|
+
* insert into
|
|
796
|
+
* characters (id, name)
|
|
797
|
+
* values
|
|
798
|
+
* (1, 'Luke'),
|
|
799
|
+
* (2, 'Leia'),
|
|
800
|
+
* (3, 'Han');
|
|
801
|
+
* ```
|
|
802
|
+
*
|
|
803
|
+
* @exampleResponse Get the execution plan
|
|
804
|
+
* ```js
|
|
805
|
+
* Aggregate (cost=33.34..33.36 rows=1 width=112)
|
|
806
|
+
* -> Limit (cost=0.00..18.33 rows=1000 width=40)
|
|
807
|
+
* -> Seq Scan on characters (cost=0.00..22.00 rows=1200 width=40)
|
|
808
|
+
* ```
|
|
809
|
+
*
|
|
810
|
+
* @exampleDescription Get the execution plan with analyze and verbose
|
|
811
|
+
* By default, the data is returned in TEXT format, but can also be returned as JSON by using the `format` parameter.
|
|
812
|
+
*
|
|
813
|
+
* @example Get the execution plan with analyze and verbose
|
|
814
|
+
* ```ts
|
|
815
|
+
* const { data, error } = await supabase
|
|
816
|
+
* .from('characters')
|
|
817
|
+
* .select()
|
|
818
|
+
* .explain({analyze:true,verbose:true})
|
|
819
|
+
* ```
|
|
820
|
+
*
|
|
821
|
+
* @exampleSql Get the execution plan with analyze and verbose
|
|
822
|
+
* ```sql
|
|
823
|
+
* create table
|
|
824
|
+
* characters (id int8 primary key, name text);
|
|
825
|
+
*
|
|
826
|
+
* insert into
|
|
827
|
+
* characters (id, name)
|
|
828
|
+
* values
|
|
829
|
+
* (1, 'Luke'),
|
|
830
|
+
* (2, 'Leia'),
|
|
831
|
+
* (3, 'Han');
|
|
832
|
+
* ```
|
|
833
|
+
*
|
|
834
|
+
* @exampleResponse Get the execution plan with analyze and verbose
|
|
835
|
+
* ```js
|
|
836
|
+
* Aggregate (cost=33.34..33.36 rows=1 width=112) (actual time=0.041..0.041 rows=1 loops=1)
|
|
837
|
+
* 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)
|
|
838
|
+
* -> Limit (cost=0.00..18.33 rows=1000 width=40) (actual time=0.005..0.006 rows=3 loops=1)
|
|
839
|
+
* Output: characters.id, characters.name
|
|
840
|
+
* -> Seq Scan on public.characters (cost=0.00..22.00 rows=1200 width=40) (actual time=0.004..0.005 rows=3 loops=1)
|
|
841
|
+
* Output: characters.id, characters.name
|
|
842
|
+
* Query Identifier: -4730654291623321173
|
|
843
|
+
* Planning Time: 0.407 ms
|
|
844
|
+
* Execution Time: 0.119 ms
|
|
845
|
+
* ```
|
|
279
846
|
*/
|
|
280
847
|
explain({
|
|
281
848
|
analyze = false,
|
|
@@ -318,6 +885,8 @@ export default class PostgrestTransformBuilder<
|
|
|
318
885
|
* Rollback the query.
|
|
319
886
|
*
|
|
320
887
|
* `data` will still be returned, but the query is not committed.
|
|
888
|
+
*
|
|
889
|
+
* @category Database
|
|
321
890
|
*/
|
|
322
891
|
rollback(): this {
|
|
323
892
|
this.headers.append('Prefer', 'tx=rollback')
|
|
@@ -329,6 +898,38 @@ export default class PostgrestTransformBuilder<
|
|
|
329
898
|
*
|
|
330
899
|
* @typeParam NewResult - The new result type to override with
|
|
331
900
|
* @deprecated Use overrideTypes<yourType, { merge: false }>() method at the end of your call chain instead
|
|
901
|
+
*
|
|
902
|
+
* @category Database
|
|
903
|
+
*
|
|
904
|
+
* @remarks
|
|
905
|
+
* - Deprecated: use overrideTypes method instead
|
|
906
|
+
*
|
|
907
|
+
* @example Override type of successful response
|
|
908
|
+
* ```ts
|
|
909
|
+
* const { data } = await supabase
|
|
910
|
+
* .from('countries')
|
|
911
|
+
* .select()
|
|
912
|
+
* .returns<Array<MyType>>()
|
|
913
|
+
* ```
|
|
914
|
+
*
|
|
915
|
+
* @exampleResponse Override type of successful response
|
|
916
|
+
* ```js
|
|
917
|
+
* let x: typeof data // MyType[]
|
|
918
|
+
* ```
|
|
919
|
+
*
|
|
920
|
+
* @example Override type of object response
|
|
921
|
+
* ```ts
|
|
922
|
+
* const { data } = await supabase
|
|
923
|
+
* .from('countries')
|
|
924
|
+
* .select()
|
|
925
|
+
* .maybeSingle()
|
|
926
|
+
* .returns<MyType>()
|
|
927
|
+
* ```
|
|
928
|
+
*
|
|
929
|
+
* @exampleResponse Override type of object response
|
|
930
|
+
* ```js
|
|
931
|
+
* let x: typeof data // MyType | null
|
|
932
|
+
* ```
|
|
332
933
|
*/
|
|
333
934
|
returns<NewResult>(): PostgrestTransformBuilder<
|
|
334
935
|
ClientOptions,
|
|
@@ -355,6 +956,8 @@ export default class PostgrestTransformBuilder<
|
|
|
355
956
|
* Only available in PostgREST v13+ and only works with PATCH and DELETE methods.
|
|
356
957
|
*
|
|
357
958
|
* @param value - The maximum number of rows that can be affected
|
|
959
|
+
*
|
|
960
|
+
* @category Database
|
|
358
961
|
*/
|
|
359
962
|
maxAffected(value: number): MaxAffectedEnabled<ClientOptions['PostgrestVersion']> extends true
|
|
360
963
|
? // TODO: update the RPC case to only work on RPC that returns SETOF rows
|
package/src/version.ts
CHANGED