You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: api-reference/v2/tables/get-table-rows.mdx
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -2,3 +2,7 @@
2
2
title: Get Rows
3
3
openapi: get /tables/{tableID}/rows
4
4
---
5
+
6
+
You can use the `limit` query parameter to specify the maximum number of rows to return for each request.
7
+
8
+
Whether or not you supply a `limit`, you may need to make multiple requests to retrieve all the rows in the table. If there are more rows to fetch, the `continuation` field will be set in the response. To retrieve the next page of rows, make another request with the `continuation` as a query parameter.
Copy file name to clipboardExpand all lines: api-reference/v2/tables/put-tables.mdx
+36-8Lines changed: 36 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -3,18 +3,27 @@ title: Overwrite Table
3
3
openapi: put /tables/{tableID}
4
4
---
5
5
6
-
Overwrite an existing Big Table by clearing all rows and adding new data. You can also update the table schema.
6
+
Overwrite an existing Big Table by clearing all rows and adding new data.
7
7
8
-
When using a CSV or TSV request body, you cannot pass a schema. The current schema will be used. If you need to update the schema, use the `onSchemaError=updateSchema` query parameter, or [stash](/api-reference/v2/stashing/introduction) the CSV/TSV data and pass a JSON request body.
8
+
### Updating the Schema
9
9
10
-
<Warning>
11
-
This is a destructive operation that cannot be undone.
12
-
</Warning>
10
+
You can optionally update the table schema at the same time by providing a new schema in the JSON request body. If you do not provide a schema, the existing schema will be used.
11
+
12
+
When using a CSV or TSV request body, you cannot pass a schema. If you need to update the schema, use the `onSchemaError=updateSchema` query parameter, or [stash](/api-reference/v2/stashing/introduction) the CSV/TSV data and pass a JSON request body referencing the stash ID.
13
13
14
14
## Examples
15
15
16
16
<AccordionGroup>
17
-
<Accordiontitle="Overwrite Table w/ Row Data">
17
+
<Accordiontitle="Clear table data">
18
+
To clear all rows from a table, send a PUT request with an empty array in the `rows` field:
19
+
20
+
```json
21
+
{
22
+
"rows": []
23
+
}
24
+
```
25
+
</Accordion>
26
+
<Accordiontitle="Reset table data">
18
27
If you want to reset a table's data with a small number of rows, you can do so by providing the data inline in the `rows` field (being sure that row object structure matches the table schema):
19
28
20
29
```json
@@ -30,15 +39,34 @@ This is a destructive operation that cannot be undone.
30
39
However, this is only appropriate for relatively small initial datasets (around a few hundred rows or less, depending on schema complexity). If you need to work with a larger dataset you should utilize stashing.
31
40
</Accordion>
32
41
33
-
<Accordiontitle="Overwrite Table from Stash">
42
+
<Accordiontitle="Reset table data from Stash">
34
43
[Stashing](/api-reference/v2/stashing/introduction) is our process for handling the upload of large datasets. Break down your dataset into smaller, more manageable, pieces and [upload them to a single stash ID](/api-reference/v2/stashing/post-stashes-serial).
35
44
36
45
Then, to reset a table's data from the stash, use the `$stashID` reference in the `rows` field instead of providing the data inline:
37
46
38
47
```json
39
48
{
40
-
"$stashID": "20240215-job32"
49
+
"rows": { "$stashID": "20240215-job32" }
41
50
}
42
51
```
43
52
</Accordion>
53
+
<Accordiontitle="Batch update table rows">
54
+
This endpoint can be combined with the [Get Rows](/api-reference/v2/tables/get-table-rows) endpoint and [stashing](/api-reference/v2/stashing/introduction) to fetch the current table data, modify it, and then overwrite the table with the updated data:
55
+
56
+
1. Call the [Get Rows](/api-reference/v2/tables/get-table-rows) endpoint to fetch the current table data. Pass a reasonably high `limit` query parameter because you want to fetch all rows in as few requests as possible.
57
+
2. Modify the data as desired, and then stash the modified rows using the [Stash Data](/api-reference/v2/stashing/put-stashes-serial) endpoint.
58
+
3. If a `continuation` was returned in step 1, repeat steps 1-3, passing the `continuation` query parameter to [Get Rows](/api-reference/v2/tables/get-table-rows) until all rows have been fetched, modified, and stashed.
59
+
4. Finally, call this endpoint with same stash ID used in step 2. This will overwrite the table with the updated data:
60
+
61
+
```json
62
+
{
63
+
"rows": { "$stashID": "20240215-job32" }
64
+
}
65
+
```
66
+
<Warning>
67
+
**Risk of Data Loss**
68
+
69
+
We strongly recommend you use the `If-Match` header to ensure the table is not modified between steps 1 and 4. See the [Data Versioning](/api-reference/v2/tables/versioning) guide for more information.
description: Detect updates and prevent data loss with versioning
4
+
---
5
+
6
+
Every Glide Big Table has a version number that increases whenever its data changes. Additionally, each row in a Big Table keeps track of the table version when it was last modified. This information can be used to detect changes to data and prevent mid-air collisions that can result in data loss.
7
+
8
+
## Getting the Current Version
9
+
10
+
Most API endpoints that work with Big Tables return the current version of the table in the `ETag` response header.
11
+
12
+
If you only want to get the current version of a table without performing any other operation, use the [Get Rows Version](/api-reference/v2/tables/head-table-rows) endpoint. You can poll this endpoint to detect changes to the table.
13
+
14
+
## Preventing Data Loss
15
+
16
+
When updating data in a Big Table, you can specify the version of the table you expect to be working with using the `If-Match` header. How this value is interpreted depends on the endpoint:
17
+
18
+
- The [Overwrite Table](/api-reference/v2/tables/put-tables) endpoint rejects the request if the current table version is newer than the version specified in the `If-Match` header.
19
+
- The [Update Row](/api-reference/v2/tables/patch-table-row) endpoint rejects the request if the row has been modified since the version specified in the `If-Match` header. The update is still allowed if another row in the table was modified since the specified version.
20
+
21
+
In both cases, an HTTP `412 Precondition Failed` response is returned if the condition is not met.
0 commit comments