Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions docs/javascript/columns.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ description: JavaScript API reference for managing columns — create, rename, r

# Columns

!!! warning "Columns cannot be created or modified from a SeaTable script"

Reading columns works in both contexts, but every write method on this page -- *Add Column*, *Rename Column*, *Column Settings* and *Delete Column* -- is only available in the external `seatable-api` client. In a JavaScript script inside a base, `base.insertColumn`, `base.deleteColumn` and the others are `undefined`.

To create or modify columns from within SeaTable, use a [Python script](../python/objects/columns.md) instead: the Python library supports the full range of column operations in both contexts, including link columns. Alternatively, call the [REST API](https://api.seatable.com/reference/insertcolumn-1) directly.

{%
include-markdown "includes.md"
start="<!--columnstructure-start-->"
Expand All @@ -27,7 +33,7 @@ description: JavaScript API reference for managing columns — create, rename, r
const column = base.getColumnByName('Table1', 'Name');
```

!!! abstract "getColumns"
!!! abstract "getColumns :material-tag-outline:{ title='Scripting only' }"

Get all columns of a table.

Expand Down Expand Up @@ -92,7 +98,7 @@ description: JavaScript API reference for managing columns — create, rename, r

## Add Column

!!! abstract "insertColumn"
!!! abstract "insertColumn :material-package-variant-closed:{ title='External client only' }"

Add a new column to a table.

Expand All @@ -118,7 +124,7 @@ description: JavaScript API reference for managing columns — create, rename, r

## Rename Column

!!! abstract "renameColumn"
!!! abstract "renameColumn :material-package-variant-closed:{ title='External client only' }"

Rename a column, identified by its column key.

Expand All @@ -133,7 +139,7 @@ description: JavaScript API reference for managing columns — create, rename, r

## Column Settings

!!! abstract "resizeColumn"
!!! abstract "resizeColumn :material-package-variant-closed:{ title='External client only' }"

```js
base.resizeColumn(tableName, columnKey, newColumnWidth);
Expand All @@ -144,7 +150,7 @@ description: JavaScript API reference for managing columns — create, rename, r
await base.resizeColumn('Table1', 'asFV', 500);
```

!!! abstract "freezeColumn"
!!! abstract "freezeColumn :material-package-variant-closed:{ title='External client only' }"

```js
base.freezeColumn(tableName, columnKey, frozen);
Expand All @@ -155,7 +161,7 @@ description: JavaScript API reference for managing columns — create, rename, r
await base.freezeColumn('Table1', '0000', true);
```

!!! abstract "moveColumn"
!!! abstract "moveColumn :material-package-variant-closed:{ title='External client only' }"

Move a column to the right of the target column.

Expand All @@ -168,7 +174,7 @@ description: JavaScript API reference for managing columns — create, rename, r
await base.moveColumn('Table1', 'loPx', '0000');
```

!!! abstract "modifyColumnType"
!!! abstract "modifyColumnType :material-package-variant-closed:{ title='External client only' }"

Change the type of an existing column.

Expand All @@ -182,7 +188,7 @@ description: JavaScript API reference for managing columns — create, rename, r
await base.modifyColumnType('Table1', 'nePI', ColumnTypes.NUMBER);
```

!!! abstract "addColumnOptions"
!!! abstract "addColumnOptions :material-package-variant-closed:{ title='External client only' }"

Add options to a single-select or multiple-select column.

Expand All @@ -198,7 +204,7 @@ description: JavaScript API reference for managing columns — create, rename, r
]);
```

!!! abstract "addColumnCascadeSettings"
!!! abstract "addColumnCascadeSettings :material-package-variant-closed:{ title='External client only' }"

Add cascade settings to a single-select column, limiting child options based on the parent column's selection.

Expand All @@ -216,7 +222,7 @@ description: JavaScript API reference for managing columns — create, rename, r

## Delete Column

!!! abstract "deleteColumn"
!!! abstract "deleteColumn :material-package-variant-closed:{ title='External client only' }"

Delete a column, identified by its column key.

Expand Down
4 changes: 4 additions & 0 deletions docs/javascript/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ When creating or modifying columns, use the `ColumnTypes` constants for type-saf
import { ColumnTypes } from 'seatable-api';
```

!!! info "External client only"

`ColumnTypes` comes from the `seatable-api` npm package. There is no `import` in the SeaTable script editor, so these constants are not available there. Since columns cannot be created or modified from a script anyway, this is not a limitation in practice -- see [Columns](columns.md).

## ColumnTypes

| Constant | Column type |
Expand Down
4 changes: 4 additions & 0 deletions docs/javascript/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ description: Upload files and images to SeaTable from JavaScript using the REST

The `seatable-api` npm package does not currently support file or image uploads. To upload files, you need to use the SeaTable REST API directly via `fetch()`.

!!! info "External client only"

The example on this page runs in Node.js: it reads from the local filesystem and authenticates with an API token. Neither is available in the SeaTable script editor.

## Upload workflow

Uploading a file to SeaTable requires three steps:
Expand Down
14 changes: 13 additions & 1 deletion docs/javascript/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Get started with the SeaTable JavaScript API. Use it inside SeaTabl

# JavaScript

SeaTable provides a JavaScript API that works in two contexts: inside SeaTable as a script, or externally via Node.js or a frontend application. The core methods (tables, views, columns, rows, links, SQL) are the same in both contexts. Features that are only available in one context are clearly marked on the respective pages.
SeaTable provides a JavaScript API that works in two contexts: inside SeaTable as a script, or externally via Node.js or a frontend application. Many methods exist in both contexts, but the two are **not** identical -- most notably, columns can only be created or modified from an external client. Every method that is limited to one context carries a marker on the respective page.

## Script vs. External Client

Expand All @@ -15,6 +15,18 @@ SeaTable provides a JavaScript API that works in two contexts: inside SeaTable a
| Execution | In the browser | Node.js or frontend app |
| `await` required | Only for `query()` and `getLinkedRecords()` | For all calls |
| Exclusive features | [Context, Output, Utilities, Filter/QuerySet](scripting-features.md) | [Constants](constants.md) |
| Column management | Read only | Full (create, modify, delete) |

### Context markers

Methods that are not available in both contexts are marked in the reference pages:

| Marker | Meaning |
|---|---|
| :material-tag-outline:{ title='Scripting only' } | Available **only** in scripts inside SeaTable. Calling it from an external client returns `undefined`. |
| :material-package-variant-closed:{ title='External client only' } | Available **only** in the external `seatable-api` client. Calling it in a SeaTable script returns `undefined`. |

Methods without a marker work in both contexts.

## Installation

Expand Down
24 changes: 22 additions & 2 deletions docs/javascript/links.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,18 @@ Link columns connect rows between tables. Most link operations require the `link

## Update Link(s)

!!! abstract "updateLink"
!!! abstract "updateLink :material-package-variant-closed:{ title='External client only' }"

Replace all linked records of a row with a new set.

```js
base.updateLink(linkId, tableName, otherTableName, rowId, otherRowIds);
```

!!! warning "Different name in scripts"

In a SeaTable script, this method is called `updateLinks` (plural) -- see below. `base.updateLink` is `undefined` in the script context.

__Example__
```js
base.updateLink('r4IJ', 'Table1', 'Table2', 'BXhEm9ucTNu3FjupIk7Xug', [
Expand All @@ -85,7 +89,23 @@ Link columns connect rows between tables. Most link operations require the `link
]);
```

!!! abstract "batchUpdateLinks"
!!! abstract "updateLinks :material-tag-outline:{ title='Scripting only' }"

Replace all linked records of a row with a new set. This is the script equivalent of `updateLink`; the parameters are identical.

```js
base.updateLinks(linkId, tableName, otherTableName, rowId, otherRowIds);
```

__Example__
```js
base.updateLinks('r4IJ', 'Table1', 'Table2', 'BXhEm9ucTNu3FjupIk7Xug', [
'exkb56fAT66j8R0w6wD9Qg',
'DjHjwmlRRB6WgU9uPnrWeA'
]);
```

!!! abstract "batchUpdateLinks :material-package-variant-closed:{ title='External client only' }"

Update links for multiple rows at once.

Expand Down
2 changes: 1 addition & 1 deletion docs/javascript/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Retrieve the complete structural schema of a SeaTable base — tabl

# Metadata

!!! abstract "getMetadata"
!!! abstract "getMetadata :material-package-variant-closed:{ title='External client only' }"

Get the complete structure of a base -- tables, views, and columns. Does not include row data.

Expand Down
12 changes: 6 additions & 6 deletions docs/javascript/rows.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ description: JavaScript API reference for row operations — query, append, inse
const row = base.getRow('Table1', 'M_lSEOYYTeuKTaHCEOL7nw');
```

!!! abstract "getRows"
!!! abstract "getRows :material-tag-outline:{ title='Scripting only' }"

Get all rows displayed in a view.

Expand All @@ -42,7 +42,7 @@ description: JavaScript API reference for row operations — query, append, inse
const rows = base.getRows('Table1', 'Default View');
```

!!! abstract "listRows"
!!! abstract "listRows :material-package-variant-closed:{ title='External client only' }"

Get rows with optional sorting and pagination. Particularly useful for large tables.

Expand Down Expand Up @@ -142,7 +142,7 @@ description: JavaScript API reference for row operations — query, append, inse
});
```

!!! abstract "insertRow"
!!! abstract "insertRow :material-package-variant-closed:{ title='External client only' }"

Insert a row after a specific anchor row.

Expand All @@ -155,7 +155,7 @@ description: JavaScript API reference for row operations — query, append, inse
await base.insertRow('Table1', {'Name': 'Inserted row'}, 'U_eTV7mDSmSd-K2P535Wzw');
```

!!! abstract "batchAppendRows"
!!! abstract "batchAppendRows :material-package-variant-closed:{ title='External client only' }"

Append multiple rows at once. More efficient than calling `appendRow` in a loop.

Expand Down Expand Up @@ -208,7 +208,7 @@ description: JavaScript API reference for row operations — query, append, inse
base.modifyRows(table, selectedRows, updates);
```

!!! abstract "batchUpdateRows"
!!! abstract "batchUpdateRows :material-package-variant-closed:{ title='External client only' }"

Update multiple rows at once. Each entry specifies a row ID and the data to update.

Expand Down Expand Up @@ -239,7 +239,7 @@ description: JavaScript API reference for row operations — query, append, inse
base.deleteRow('Table1', 'U_eTV7mDSmSd-K2P535Wzw');
```

!!! abstract "batchDeleteRows"
!!! abstract "batchDeleteRows :material-package-variant-closed:{ title='External client only' }"

Delete multiple rows at once.

Expand Down
Loading