Skip to content

Tables

All available functions to interact with the tables of a SeaTable base.

Get Table(s)

getActiveTable

Get the currently selected table and return a table object.

base.getActiveTable();

Example

const table = base.getActiveTable();
output.text(`The name of the active table is: ${table.name}`);

getTables

Get all tables of this base as json object with all rows and metadata.

base.getTables();

Example

const tables = base.getTables();
output.text(tables);

getTableByName

Get a table object by its name. The object contains all rows and metadata.

base.getTableByName(tableName: String);

Example

const table = base.getTableByName('Table1');
output.text(`The id of the table is: ${table._id}`);

Add Table

addTable

Add a new table to this base. The table should not exist already in your base.

base.addTable(tableName: String);

Example

base.addTable('New table');
output.text("Wow, I just added a new table to this base.")

Rename Table

renameTable

Rename an existing table.

base.renameTable(oldName: String, newName: String);

Example

const old_name = "Table1";
const new_name = "Projects 2023";
base.renameTable(old_name, new_name);
output.text(`This base ${old_name} got a new name: ${new_name}`);

Delete Table

deleteTable

Delete a table from the base. By the way, the table can be restored from the logs.

base.deleteTable(tableName: String);

Example

base.deleteTable('Old table');