Links¶
Link operations on the seatable-html-page-sdk. Use these methods to add or remove particular relationships without replacing the entire value of a link column. All methods are asynchronous — await them. The sdk instance below is created and initialized as shown in Initialization.
Response format
Link methods resolve to the underlying HTTP response. Read the payload from .data. Single-row methods return the updated source row in .data.row; batch methods return updated source rows in .data.rows.
Add and delete one link¶
addLink
Add one linked record to a link-column cell without replacing its existing links.
Note: This was added in SDK version 1.0-latest.
Parameters
tableName- string — name of the table containing the link column
rowId- string — the
_idof the source row intableName linkColumnName- string — name of the link column; use its display name, not its internal key
otherRowId- string — the
_idof the record to add from the link column's configured target table
Returns .data holds { success: true, row } — row is the updated source row.
Example
deleteLink
Delete one linked record from a link-column cell without changing its other links.
Note: This was added in SDK version 1.0-latest.
Parameters
tableName- string — name of the table containing the link column
rowId- string — the
_idof the source row intableName linkColumnName- string — name of the link column; use its display name, not its internal key
otherRowId- string — the
_idof the record to remove from the link column's configured target table
Returns .data holds { success: true, row } — row is the updated source row.
Example
Add and delete links in batches¶
batchAddLinks
Add links to one or more rows in the same source table.
Note: This was added in SDK version 1.0-latest.
Parameters
tableName- string — name of the table containing the link columns
linksData- array — row-oriented link changes. Each item has a
row_idsource-row ID and alinksobject. Eachlinkskey is a link column display name and its value is an array of linked row IDs.
Returns .data holds { success: true, rows } — rows is the array of updated source rows.
Example
const res = await sdk.batchAddLinks({
tableName: "Tasks",
linksData: [
{
row_id: "fcHIocncTsOygA3FjL-toQ",
links: {
"Related projects": ["NSPa_fd4SEqRESqOZzRqyg", "eA6rQDuxQyGITmD1hrfyzw"],
Reviewers: ["bBDbhbzXReSPWpcxq225xA", "NSPa_fd4SEqRESqOZzRqyg"],
},
},
{
row_id: "BIXJ_dUMS1OW8Lyoxrx4Fw",
links: {
"Related projects": ["eA6rQDuxQyGITmD1hrfyzw", "QgK2KMf8Sxad8duPcq6gQA"],
},
},
],
});
const updatedRows = res.data.rows;
batchDeleteLinks
Delete specified links from one or more rows in the same source table. Links not listed in linksData remain unchanged.
Note: This was added in SDK version 1.0-latest.
Parameters
tableName- string — name of the table containing the link columns
linksData- array — row-oriented link changes. Each item has a
row_idsource-row ID and alinksobject. Eachlinkskey is a link column display name and its value is an array of linked row IDs to remove.
Returns .data holds { success: true, rows } — rows is the array of updated source rows.
Example
const res = await sdk.batchDeleteLinks({
tableName: "Tasks",
linksData: [
{
row_id: "fcHIocncTsOygA3FjL-toQ",
links: {
"Related projects": ["NSPa_fd4SEqRESqOZzRqyg", "eA6rQDuxQyGITmD1hrfyzw"],
},
},
{
row_id: "BIXJ_dUMS1OW8Lyoxrx4Fw",
links: {
"Related projects": ["eA6rQDuxQyGITmD1hrfyzw"],
},
},
],
});
const updatedRows = res.data.rows;
Notes¶
- Use
updateRoworbatchUpdateRowsfrom Rows when you want to replace a link-column value with the complete array of linked row IDs while updating other fields. Use the APIs on this page for incremental additions or removals.