@supabase/postgrest-js 2.99.0 → 2.99.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1175,30 +1175,784 @@ declare class PostgrestQueryBuilder<ClientOptions extends ClientServerOptions, S
1175
1175
  */
1176
1176
  private cloneRequestState;
1177
1177
  /**
1178
- * Perform a SELECT query on the table or view.
1179
- *
1180
- * @param columns - The columns to retrieve, separated by commas. Columns can be renamed when returned with `customName:columnName`
1181
- *
1182
- * @param options - Named parameters
1183
- *
1184
- * @param options.head - When set to `true`, `data` will not be returned.
1185
- * Useful if you only need the count.
1186
- *
1187
- * @param options.count - Count algorithm to use to count rows in the table or view.
1188
- *
1189
- * `"exact"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the
1190
- * hood.
1191
- *
1192
- * `"planned"`: Approximated but fast count algorithm. Uses the Postgres
1193
- * statistics under the hood.
1194
- *
1195
- * `"estimated"`: Uses exact count for low numbers and planned count for high
1196
- * numbers.
1197
- *
1198
- * @remarks
1199
- * When using `count` with `.range()` or `.limit()`, the returned `count` is the total number of rows
1200
- * that match your filters, not the number of rows in the current page. Use this to build pagination UI.
1201
- */
1178
+ * Perform a SELECT query on the table or view.
1179
+ *
1180
+ * @param columns - The columns to retrieve, separated by commas. Columns can be renamed when returned with `customName:columnName`
1181
+ *
1182
+ * @param options - Named parameters
1183
+ *
1184
+ * @param options.head - When set to `true`, `data` will not be returned.
1185
+ * Useful if you only need the count.
1186
+ *
1187
+ * @param options.count - Count algorithm to use to count rows in the table or view.
1188
+ *
1189
+ * `"exact"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the
1190
+ * hood.
1191
+ *
1192
+ * `"planned"`: Approximated but fast count algorithm. Uses the Postgres
1193
+ * statistics under the hood.
1194
+ *
1195
+ * `"estimated"`: Uses exact count for low numbers and planned count for high
1196
+ * numbers.
1197
+ *
1198
+ * @remarks
1199
+ * When using `count` with `.range()` or `.limit()`, the returned `count` is the total number of rows
1200
+ * that match your filters, not the number of rows in the current page. Use this to build pagination UI.
1201
+
1202
+ * - By default, Supabase projects return a maximum of 1,000 rows. This setting can be changed in your project's [API settings](/dashboard/project/_/settings/api). It's recommended that you keep it low to limit the payload size of accidental or malicious requests. You can use `range()` queries to paginate through your data.
1203
+ * - `select()` can be combined with [Filters](/docs/reference/javascript/using-filters)
1204
+ * - `select()` can be combined with [Modifiers](/docs/reference/javascript/using-modifiers)
1205
+ * - `apikey` is a reserved keyword if you're using the [Supabase Platform](/docs/guides/platform) and [should be avoided as a column name](https://github.com/supabase/supabase/issues/5465). *
1206
+ * @category Database
1207
+ *
1208
+ * @example Getting your data
1209
+ * ```js
1210
+ * const { data, error } = await supabase
1211
+ * .from('characters')
1212
+ * .select()
1213
+ * ```
1214
+ *
1215
+ * @exampleSql Getting your data
1216
+ * ```sql
1217
+ * create table
1218
+ * characters (id int8 primary key, name text);
1219
+ *
1220
+ * insert into
1221
+ * characters (id, name)
1222
+ * values
1223
+ * (1, 'Harry'),
1224
+ * (2, 'Frodo'),
1225
+ * (3, 'Katniss');
1226
+ * ```
1227
+ *
1228
+ * @exampleResponse Getting your data
1229
+ * ```json
1230
+ * {
1231
+ * "data": [
1232
+ * {
1233
+ * "id": 1,
1234
+ * "name": "Harry"
1235
+ * },
1236
+ * {
1237
+ * "id": 2,
1238
+ * "name": "Frodo"
1239
+ * },
1240
+ * {
1241
+ * "id": 3,
1242
+ * "name": "Katniss"
1243
+ * }
1244
+ * ],
1245
+ * "status": 200,
1246
+ * "statusText": "OK"
1247
+ * }
1248
+ * ```
1249
+ *
1250
+ * @example Selecting specific columns
1251
+ * ```js
1252
+ * const { data, error } = await supabase
1253
+ * .from('characters')
1254
+ * .select('name')
1255
+ * ```
1256
+ *
1257
+ * @exampleSql Selecting specific columns
1258
+ * ```sql
1259
+ * create table
1260
+ * characters (id int8 primary key, name text);
1261
+ *
1262
+ * insert into
1263
+ * characters (id, name)
1264
+ * values
1265
+ * (1, 'Frodo'),
1266
+ * (2, 'Harry'),
1267
+ * (3, 'Katniss');
1268
+ * ```
1269
+ *
1270
+ * @exampleResponse Selecting specific columns
1271
+ * ```json
1272
+ * {
1273
+ * "data": [
1274
+ * {
1275
+ * "name": "Frodo"
1276
+ * },
1277
+ * {
1278
+ * "name": "Harry"
1279
+ * },
1280
+ * {
1281
+ * "name": "Katniss"
1282
+ * }
1283
+ * ],
1284
+ * "status": 200,
1285
+ * "statusText": "OK"
1286
+ * }
1287
+ * ```
1288
+ *
1289
+ * @exampleDescription Query referenced tables
1290
+ * If your database has foreign key relationships, you can query related tables too.
1291
+ *
1292
+ * @example Query referenced tables
1293
+ * ```js
1294
+ * const { data, error } = await supabase
1295
+ * .from('orchestral_sections')
1296
+ * .select(`
1297
+ * name,
1298
+ * instruments (
1299
+ * name
1300
+ * )
1301
+ * `)
1302
+ * ```
1303
+ *
1304
+ * @exampleSql Query referenced tables
1305
+ * ```sql
1306
+ * create table
1307
+ * orchestral_sections (id int8 primary key, name text);
1308
+ * create table
1309
+ * instruments (
1310
+ * id int8 primary key,
1311
+ * section_id int8 not null references orchestral_sections,
1312
+ * name text
1313
+ * );
1314
+ *
1315
+ * insert into
1316
+ * orchestral_sections (id, name)
1317
+ * values
1318
+ * (1, 'strings'),
1319
+ * (2, 'woodwinds');
1320
+ * insert into
1321
+ * instruments (id, section_id, name)
1322
+ * values
1323
+ * (1, 2, 'flute'),
1324
+ * (2, 1, 'violin');
1325
+ * ```
1326
+ *
1327
+ * @exampleResponse Query referenced tables
1328
+ * ```json
1329
+ * {
1330
+ * "data": [
1331
+ * {
1332
+ * "name": "strings",
1333
+ * "instruments": [
1334
+ * {
1335
+ * "name": "violin"
1336
+ * }
1337
+ * ]
1338
+ * },
1339
+ * {
1340
+ * "name": "woodwinds",
1341
+ * "instruments": [
1342
+ * {
1343
+ * "name": "flute"
1344
+ * }
1345
+ * ]
1346
+ * }
1347
+ * ],
1348
+ * "status": 200,
1349
+ * "statusText": "OK"
1350
+ * }
1351
+ * ```
1352
+ *
1353
+ * @exampleDescription Query referenced tables with spaces in their names
1354
+ * If your table name contains spaces, you must use double quotes in the `select` statement to reference the table.
1355
+ *
1356
+ * @example Query referenced tables with spaces in their names
1357
+ * ```js
1358
+ * const { data, error } = await supabase
1359
+ * .from('orchestral sections')
1360
+ * .select(`
1361
+ * name,
1362
+ * "musical instruments" (
1363
+ * name
1364
+ * )
1365
+ * `)
1366
+ * ```
1367
+ *
1368
+ * @exampleSql Query referenced tables with spaces in their names
1369
+ * ```sql
1370
+ * create table
1371
+ * "orchestral sections" (id int8 primary key, name text);
1372
+ * create table
1373
+ * "musical instruments" (
1374
+ * id int8 primary key,
1375
+ * section_id int8 not null references "orchestral sections",
1376
+ * name text
1377
+ * );
1378
+ *
1379
+ * insert into
1380
+ * "orchestral sections" (id, name)
1381
+ * values
1382
+ * (1, 'strings'),
1383
+ * (2, 'woodwinds');
1384
+ * insert into
1385
+ * "musical instruments" (id, section_id, name)
1386
+ * values
1387
+ * (1, 2, 'flute'),
1388
+ * (2, 1, 'violin');
1389
+ * ```
1390
+ *
1391
+ * @exampleResponse Query referenced tables with spaces in their names
1392
+ * ```json
1393
+ * {
1394
+ * "data": [
1395
+ * {
1396
+ * "name": "strings",
1397
+ * "musical instruments": [
1398
+ * {
1399
+ * "name": "violin"
1400
+ * }
1401
+ * ]
1402
+ * },
1403
+ * {
1404
+ * "name": "woodwinds",
1405
+ * "musical instruments": [
1406
+ * {
1407
+ * "name": "flute"
1408
+ * }
1409
+ * ]
1410
+ * }
1411
+ * ],
1412
+ * "status": 200,
1413
+ * "statusText": "OK"
1414
+ * }
1415
+ * ```
1416
+ *
1417
+ * @exampleDescription Query referenced tables through a join table
1418
+ * If you're in a situation where your tables are **NOT** directly
1419
+ * related, but instead are joined by a _join table_, you can still use
1420
+ * the `select()` method to query the related data. The join table needs
1421
+ * to have the foreign keys as part of its composite primary key.
1422
+ *
1423
+ * @example Query referenced tables through a join table
1424
+ * ```ts
1425
+ * const { data, error } = await supabase
1426
+ * .from('users')
1427
+ * .select(`
1428
+ * name,
1429
+ * teams (
1430
+ * name
1431
+ * )
1432
+ * `)
1433
+ *
1434
+ * ```
1435
+ *
1436
+ * @exampleSql Query referenced tables through a join table
1437
+ * ```sql
1438
+ * create table
1439
+ * users (
1440
+ * id int8 primary key,
1441
+ * name text
1442
+ * );
1443
+ * create table
1444
+ * teams (
1445
+ * id int8 primary key,
1446
+ * name text
1447
+ * );
1448
+ * -- join table
1449
+ * create table
1450
+ * users_teams (
1451
+ * user_id int8 not null references users,
1452
+ * team_id int8 not null references teams,
1453
+ * -- both foreign keys must be part of a composite primary key
1454
+ * primary key (user_id, team_id)
1455
+ * );
1456
+ *
1457
+ * insert into
1458
+ * users (id, name)
1459
+ * values
1460
+ * (1, 'Kiran'),
1461
+ * (2, 'Evan');
1462
+ * insert into
1463
+ * teams (id, name)
1464
+ * values
1465
+ * (1, 'Green'),
1466
+ * (2, 'Blue');
1467
+ * insert into
1468
+ * users_teams (user_id, team_id)
1469
+ * values
1470
+ * (1, 1),
1471
+ * (1, 2),
1472
+ * (2, 2);
1473
+ * ```
1474
+ *
1475
+ * @exampleResponse Query referenced tables through a join table
1476
+ * ```json
1477
+ * {
1478
+ * "data": [
1479
+ * {
1480
+ * "name": "Kiran",
1481
+ * "teams": [
1482
+ * {
1483
+ * "name": "Green"
1484
+ * },
1485
+ * {
1486
+ * "name": "Blue"
1487
+ * }
1488
+ * ]
1489
+ * },
1490
+ * {
1491
+ * "name": "Evan",
1492
+ * "teams": [
1493
+ * {
1494
+ * "name": "Blue"
1495
+ * }
1496
+ * ]
1497
+ * }
1498
+ * ],
1499
+ * "status": 200,
1500
+ * "statusText": "OK"
1501
+ * }
1502
+ *
1503
+ * ```
1504
+ *
1505
+ * @exampleDescription Query the same referenced table multiple times
1506
+ * If you need to query the same referenced table twice, use the name of the
1507
+ * joined column to identify which join to use. You can also give each
1508
+ * column an alias.
1509
+ *
1510
+ * @example Query the same referenced table multiple times
1511
+ * ```ts
1512
+ * const { data, error } = await supabase
1513
+ * .from('messages')
1514
+ * .select(`
1515
+ * content,
1516
+ * from:sender_id(name),
1517
+ * to:receiver_id(name)
1518
+ * `)
1519
+ *
1520
+ * // To infer types, use the name of the table (in this case `users`) and
1521
+ * // the name of the foreign key constraint.
1522
+ * const { data, error } = await supabase
1523
+ * .from('messages')
1524
+ * .select(`
1525
+ * content,
1526
+ * from:users!messages_sender_id_fkey(name),
1527
+ * to:users!messages_receiver_id_fkey(name)
1528
+ * `)
1529
+ * ```
1530
+ *
1531
+ * @exampleSql Query the same referenced table multiple times
1532
+ * ```sql
1533
+ * create table
1534
+ * users (id int8 primary key, name text);
1535
+ *
1536
+ * create table
1537
+ * messages (
1538
+ * sender_id int8 not null references users,
1539
+ * receiver_id int8 not null references users,
1540
+ * content text
1541
+ * );
1542
+ *
1543
+ * insert into
1544
+ * users (id, name)
1545
+ * values
1546
+ * (1, 'Kiran'),
1547
+ * (2, 'Evan');
1548
+ *
1549
+ * insert into
1550
+ * messages (sender_id, receiver_id, content)
1551
+ * values
1552
+ * (1, 2, '👋');
1553
+ * ```
1554
+ * ```
1555
+ *
1556
+ * @exampleResponse Query the same referenced table multiple times
1557
+ * ```json
1558
+ * {
1559
+ * "data": [
1560
+ * {
1561
+ * "content": "👋",
1562
+ * "from": {
1563
+ * "name": "Kiran"
1564
+ * },
1565
+ * "to": {
1566
+ * "name": "Evan"
1567
+ * }
1568
+ * }
1569
+ * ],
1570
+ * "status": 200,
1571
+ * "statusText": "OK"
1572
+ * }
1573
+ * ```
1574
+ *
1575
+ * @exampleDescription Query nested foreign tables through a join table
1576
+ * You can use the result of a joined table to gather data in
1577
+ * another foreign table. With multiple references to the same foreign
1578
+ * table you must specify the column on which to conduct the join.
1579
+ *
1580
+ * @example Query nested foreign tables through a join table
1581
+ * ```ts
1582
+ * const { data, error } = await supabase
1583
+ * .from('games')
1584
+ * .select(`
1585
+ * game_id:id,
1586
+ * away_team:teams!games_away_team_fkey (
1587
+ * users (
1588
+ * id,
1589
+ * name
1590
+ * )
1591
+ * )
1592
+ * `)
1593
+ *
1594
+ * ```
1595
+ *
1596
+ * @exampleSql Query nested foreign tables through a join table
1597
+ * ```sql
1598
+ * ```sql
1599
+ * create table
1600
+ * users (
1601
+ * id int8 primary key,
1602
+ * name text
1603
+ * );
1604
+ * create table
1605
+ * teams (
1606
+ * id int8 primary key,
1607
+ * name text
1608
+ * );
1609
+ * -- join table
1610
+ * create table
1611
+ * users_teams (
1612
+ * user_id int8 not null references users,
1613
+ * team_id int8 not null references teams,
1614
+ *
1615
+ * primary key (user_id, team_id)
1616
+ * );
1617
+ * create table
1618
+ * games (
1619
+ * id int8 primary key,
1620
+ * home_team int8 not null references teams,
1621
+ * away_team int8 not null references teams,
1622
+ * name text
1623
+ * );
1624
+ *
1625
+ * insert into users (id, name)
1626
+ * values
1627
+ * (1, 'Kiran'),
1628
+ * (2, 'Evan');
1629
+ * insert into
1630
+ * teams (id, name)
1631
+ * values
1632
+ * (1, 'Green'),
1633
+ * (2, 'Blue');
1634
+ * insert into
1635
+ * users_teams (user_id, team_id)
1636
+ * values
1637
+ * (1, 1),
1638
+ * (1, 2),
1639
+ * (2, 2);
1640
+ * insert into
1641
+ * games (id, home_team, away_team, name)
1642
+ * values
1643
+ * (1, 1, 2, 'Green vs Blue'),
1644
+ * (2, 2, 1, 'Blue vs Green');
1645
+ * ```
1646
+ *
1647
+ * @exampleResponse Query nested foreign tables through a join table
1648
+ * ```json
1649
+ * {
1650
+ * "data": [
1651
+ * {
1652
+ * "game_id": 1,
1653
+ * "away_team": {
1654
+ * "users": [
1655
+ * {
1656
+ * "id": 1,
1657
+ * "name": "Kiran"
1658
+ * },
1659
+ * {
1660
+ * "id": 2,
1661
+ * "name": "Evan"
1662
+ * }
1663
+ * ]
1664
+ * }
1665
+ * },
1666
+ * {
1667
+ * "game_id": 2,
1668
+ * "away_team": {
1669
+ * "users": [
1670
+ * {
1671
+ * "id": 1,
1672
+ * "name": "Kiran"
1673
+ * }
1674
+ * ]
1675
+ * }
1676
+ * }
1677
+ * ],
1678
+ * "status": 200,
1679
+ * "statusText": "OK"
1680
+ * }
1681
+ *
1682
+ * ```
1683
+ *
1684
+ * @exampleDescription Filtering through referenced tables
1685
+ * If the filter on a referenced table's column is not satisfied, the referenced
1686
+ * table returns `[]` or `null` but the parent table is not filtered out.
1687
+ * If you want to filter out the parent table rows, use the `!inner` hint
1688
+ *
1689
+ * @example Filtering through referenced tables
1690
+ * ```ts
1691
+ * const { data, error } = await supabase
1692
+ * .from('instruments')
1693
+ * .select('name, orchestral_sections(*)')
1694
+ * .eq('orchestral_sections.name', 'percussion')
1695
+ * ```
1696
+ *
1697
+ * @exampleSql Filtering through referenced tables
1698
+ * ```sql
1699
+ * create table
1700
+ * orchestral_sections (id int8 primary key, name text);
1701
+ * create table
1702
+ * instruments (
1703
+ * id int8 primary key,
1704
+ * section_id int8 not null references orchestral_sections,
1705
+ * name text
1706
+ * );
1707
+ *
1708
+ * insert into
1709
+ * orchestral_sections (id, name)
1710
+ * values
1711
+ * (1, 'strings'),
1712
+ * (2, 'woodwinds');
1713
+ * insert into
1714
+ * instruments (id, section_id, name)
1715
+ * values
1716
+ * (1, 2, 'flute'),
1717
+ * (2, 1, 'violin');
1718
+ * ```
1719
+ *
1720
+ * @exampleResponse Filtering through referenced tables
1721
+ * ```json
1722
+ * {
1723
+ * "data": [
1724
+ * {
1725
+ * "name": "flute",
1726
+ * "orchestral_sections": null
1727
+ * },
1728
+ * {
1729
+ * "name": "violin",
1730
+ * "orchestral_sections": null
1731
+ * }
1732
+ * ],
1733
+ * "status": 200,
1734
+ * "statusText": "OK"
1735
+ * }
1736
+ * ```
1737
+ *
1738
+ * @exampleDescription Querying referenced table with count
1739
+ * You can get the number of rows in a related table by using the
1740
+ * **count** property.
1741
+ *
1742
+ * @example Querying referenced table with count
1743
+ * ```ts
1744
+ * const { data, error } = await supabase
1745
+ * .from('orchestral_sections')
1746
+ * .select(`*, instruments(count)`)
1747
+ * ```
1748
+ *
1749
+ * @exampleSql Querying referenced table with count
1750
+ * ```sql
1751
+ * create table orchestral_sections (
1752
+ * "id" "uuid" primary key default "extensions"."uuid_generate_v4"() not null,
1753
+ * "name" text
1754
+ * );
1755
+ *
1756
+ * create table characters (
1757
+ * "id" "uuid" primary key default "extensions"."uuid_generate_v4"() not null,
1758
+ * "name" text,
1759
+ * "section_id" "uuid" references public.orchestral_sections on delete cascade
1760
+ * );
1761
+ *
1762
+ * with section as (
1763
+ * insert into orchestral_sections (name)
1764
+ * values ('strings') returning id
1765
+ * )
1766
+ * insert into instruments (name, section_id) values
1767
+ * ('violin', (select id from section)),
1768
+ * ('viola', (select id from section)),
1769
+ * ('cello', (select id from section)),
1770
+ * ('double bass', (select id from section));
1771
+ * ```
1772
+ *
1773
+ * @exampleResponse Querying referenced table with count
1774
+ * ```json
1775
+ * [
1776
+ * {
1777
+ * "id": "693694e7-d993-4360-a6d7-6294e325d9b6",
1778
+ * "name": "strings",
1779
+ * "instruments": [
1780
+ * {
1781
+ * "count": 4
1782
+ * }
1783
+ * ]
1784
+ * }
1785
+ * ]
1786
+ * ```
1787
+ *
1788
+ * @exampleDescription Querying with count option
1789
+ * You can get the number of rows by using the
1790
+ * [count](/docs/reference/javascript/select#parameters) option.
1791
+ *
1792
+ * @example Querying with count option
1793
+ * ```ts
1794
+ * const { count, error } = await supabase
1795
+ * .from('characters')
1796
+ * .select('*', { count: 'exact', head: true })
1797
+ * ```
1798
+ *
1799
+ * @exampleSql Querying with count option
1800
+ * ```sql
1801
+ * create table
1802
+ * characters (id int8 primary key, name text);
1803
+ *
1804
+ * insert into
1805
+ * characters (id, name)
1806
+ * values
1807
+ * (1, 'Luke'),
1808
+ * (2, 'Leia'),
1809
+ * (3, 'Han');
1810
+ * ```
1811
+ *
1812
+ * @exampleResponse Querying with count option
1813
+ * ```json
1814
+ * {
1815
+ * "count": 3,
1816
+ * "status": 200,
1817
+ * "statusText": "OK"
1818
+ * }
1819
+ * ```
1820
+ *
1821
+ * @exampleDescription Querying JSON data
1822
+ * You can select and filter data inside of
1823
+ * [JSON](/docs/guides/database/json) columns. Postgres offers some
1824
+ * [operators](/docs/guides/database/json#query-the-jsonb-data) for
1825
+ * querying JSON data.
1826
+ *
1827
+ * @example Querying JSON data
1828
+ * ```ts
1829
+ * const { data, error } = await supabase
1830
+ * .from('users')
1831
+ * .select(`
1832
+ * id, name,
1833
+ * address->city
1834
+ * `)
1835
+ * ```
1836
+ *
1837
+ * @exampleSql Querying JSON data
1838
+ * ```sql
1839
+ * create table
1840
+ * users (
1841
+ * id int8 primary key,
1842
+ * name text,
1843
+ * address jsonb
1844
+ * );
1845
+ *
1846
+ * insert into
1847
+ * users (id, name, address)
1848
+ * values
1849
+ * (1, 'Frodo', '{"city":"Hobbiton"}');
1850
+ * ```
1851
+ *
1852
+ * @exampleResponse Querying JSON data
1853
+ * ```json
1854
+ * {
1855
+ * "data": [
1856
+ * {
1857
+ * "id": 1,
1858
+ * "name": "Frodo",
1859
+ * "city": "Hobbiton"
1860
+ * }
1861
+ * ],
1862
+ * "status": 200,
1863
+ * "statusText": "OK"
1864
+ * }
1865
+ * ```
1866
+ *
1867
+ * @exampleDescription Querying referenced table with inner join
1868
+ * If you don't want to return the referenced table contents, you can leave the parenthesis empty.
1869
+ * Like `.select('name, orchestral_sections!inner()')`.
1870
+ *
1871
+ * @example Querying referenced table with inner join
1872
+ * ```ts
1873
+ * const { data, error } = await supabase
1874
+ * .from('instruments')
1875
+ * .select('name, orchestral_sections!inner(name)')
1876
+ * .eq('orchestral_sections.name', 'woodwinds')
1877
+ * .limit(1)
1878
+ * ```
1879
+ *
1880
+ * @exampleSql Querying referenced table with inner join
1881
+ * ```sql
1882
+ * create table orchestral_sections (
1883
+ * "id" "uuid" primary key default "extensions"."uuid_generate_v4"() not null,
1884
+ * "name" text
1885
+ * );
1886
+ *
1887
+ * create table instruments (
1888
+ * "id" "uuid" primary key default "extensions"."uuid_generate_v4"() not null,
1889
+ * "name" text,
1890
+ * "section_id" "uuid" references public.orchestral_sections on delete cascade
1891
+ * );
1892
+ *
1893
+ * with section as (
1894
+ * insert into orchestral_sections (name)
1895
+ * values ('woodwinds') returning id
1896
+ * )
1897
+ * insert into instruments (name, section_id) values
1898
+ * ('flute', (select id from section)),
1899
+ * ('clarinet', (select id from section)),
1900
+ * ('bassoon', (select id from section)),
1901
+ * ('piccolo', (select id from section));
1902
+ * ```
1903
+ *
1904
+ * @exampleResponse Querying referenced table with inner join
1905
+ * ```json
1906
+ * {
1907
+ * "data": [
1908
+ * {
1909
+ * "name": "flute",
1910
+ * "orchestral_sections": {"name": "woodwinds"}
1911
+ * }
1912
+ * ],
1913
+ * "status": 200,
1914
+ * "statusText": "OK"
1915
+ * }
1916
+ * ```
1917
+ *
1918
+ * @exampleDescription Switching schemas per query
1919
+ * In addition to setting the schema during initialization, you can also switch schemas on a per-query basis.
1920
+ * Make sure you've set up your [database privileges and API settings](/docs/guides/api/using-custom-schemas).
1921
+ *
1922
+ * @example Switching schemas per query
1923
+ * ```ts
1924
+ * const { data, error } = await supabase
1925
+ * .schema('myschema')
1926
+ * .from('mytable')
1927
+ * .select()
1928
+ * ```
1929
+ *
1930
+ * @exampleSql Switching schemas per query
1931
+ * ```sql
1932
+ * create schema myschema;
1933
+ *
1934
+ * create table myschema.mytable (
1935
+ * id uuid primary key default gen_random_uuid(),
1936
+ * data text
1937
+ * );
1938
+ *
1939
+ * insert into myschema.mytable (data) values ('mydata');
1940
+ * ```
1941
+ *
1942
+ * @exampleResponse Switching schemas per query
1943
+ * ```json
1944
+ * {
1945
+ * "data": [
1946
+ * {
1947
+ * "id": "4162e008-27b0-4c0f-82dc-ccaeee9a624d",
1948
+ * "data": "mydata"
1949
+ * }
1950
+ * ],
1951
+ * "status": 200,
1952
+ * "statusText": "OK"
1953
+ * }
1954
+ * ```
1955
+ */
1202
1956
  select<Query extends string = '*', ResultOne = GetResult<Schema, Relation$1['Row'], RelationName, Relationships, Query, ClientOptions>>(columns?: Query, options?: {
1203
1957
  head?: boolean;
1204
1958
  count?: 'exact' | 'planned' | 'estimated';
@@ -1249,6 +2003,124 @@ declare class PostgrestQueryBuilder<ClientOptions extends ClientServerOptions, S
1249
2003
  *
1250
2004
  * `"estimated"`: Uses exact count for low numbers and planned count for high
1251
2005
  * numbers.
2006
+ *
2007
+ * @category Database
2008
+ *
2009
+ * @remarks
2010
+ * - `update()` should always be combined with [Filters](/docs/reference/javascript/using-filters) to target the item(s) you wish to update.
2011
+ *
2012
+ * @example Updating your data
2013
+ * ```ts
2014
+ * const { error } = await supabase
2015
+ * .from('instruments')
2016
+ * .update({ name: 'piano' })
2017
+ * .eq('id', 1)
2018
+ * ```
2019
+ *
2020
+ * @exampleSql Updating your data
2021
+ * ```sql
2022
+ * create table
2023
+ * instruments (id int8 primary key, name text);
2024
+ *
2025
+ * insert into
2026
+ * instruments (id, name)
2027
+ * values
2028
+ * (1, 'harpsichord');
2029
+ * ```
2030
+ *
2031
+ * @exampleResponse Updating your data
2032
+ * ```json
2033
+ * {
2034
+ * "status": 204,
2035
+ * "statusText": "No Content"
2036
+ * }
2037
+ * ```
2038
+ *
2039
+ * @example Update a record and return it
2040
+ * ```ts
2041
+ * const { data, error } = await supabase
2042
+ * .from('instruments')
2043
+ * .update({ name: 'piano' })
2044
+ * .eq('id', 1)
2045
+ * .select()
2046
+ * ```
2047
+ *
2048
+ * @exampleSql Update a record and return it
2049
+ * ```sql
2050
+ * create table
2051
+ * instruments (id int8 primary key, name text);
2052
+ *
2053
+ * insert into
2054
+ * instruments (id, name)
2055
+ * values
2056
+ * (1, 'harpsichord');
2057
+ * ```
2058
+ *
2059
+ * @exampleResponse Update a record and return it
2060
+ * ```json
2061
+ * {
2062
+ * "data": [
2063
+ * {
2064
+ * "id": 1,
2065
+ * "name": "piano"
2066
+ * }
2067
+ * ],
2068
+ * "status": 200,
2069
+ * "statusText": "OK"
2070
+ * }
2071
+ * ```
2072
+ *
2073
+ * @exampleDescription Updating JSON data
2074
+ * Postgres offers some
2075
+ * [operators](/docs/guides/database/json#query-the-jsonb-data) for
2076
+ * working with JSON data. Currently, it is only possible to update the entire JSON document.
2077
+ *
2078
+ * @example Updating JSON data
2079
+ * ```ts
2080
+ * const { data, error } = await supabase
2081
+ * .from('users')
2082
+ * .update({
2083
+ * address: {
2084
+ * street: 'Melrose Place',
2085
+ * postcode: 90210
2086
+ * }
2087
+ * })
2088
+ * .eq('address->postcode', 90210)
2089
+ * .select()
2090
+ * ```
2091
+ *
2092
+ * @exampleSql Updating JSON data
2093
+ * ```sql
2094
+ * create table
2095
+ * users (
2096
+ * id int8 primary key,
2097
+ * name text,
2098
+ * address jsonb
2099
+ * );
2100
+ *
2101
+ * insert into
2102
+ * users (id, name, address)
2103
+ * values
2104
+ * (1, 'Michael', '{ "postcode": 90210 }');
2105
+ * ```
2106
+ *
2107
+ * @exampleResponse Updating JSON data
2108
+ * ```json
2109
+ * {
2110
+ * "data": [
2111
+ * {
2112
+ * "id": 1,
2113
+ * "name": "Michael",
2114
+ * "address": {
2115
+ * "street": "Melrose Place",
2116
+ * "postcode": 90210
2117
+ * }
2118
+ * }
2119
+ * ],
2120
+ * "status": 200,
2121
+ * "statusText": "OK"
2122
+ * }
2123
+ * ```
1252
2124
  */
1253
2125
  update<Row extends (Relation$1 extends {
1254
2126
  Update: unknown;