跳转到内容

Schema SDK

eidos.space.schema 对象提供了管理表、字段和视图生命周期的各种方法。

创建一个包含指定字段的新表。

async createTable(input: CreateTableInput): Promise<TableInfo>

示例:

const table = await eidos.space.schema.createTable({
name: "任务清单",
fields: [
{ name: "优先级", columnName: "priority", type: "select", property: {
options: [{ name: "", color: "red" }, { name: "", color: "blue" }]
}},
{ name: "截止日期", columnName: "deadline", type: "date" }
]
})
console.log("创建的表格 ID:", table.id)

获取特定表的详细信息。

async getTable(tableId: string): Promise<TableInfo>

示例:

const tableInfo = await eidos.space.schema.getTable("table_id_here")
console.log(`表格 ${tableInfo.name} 共有 ${tableInfo.fields.length} 个字段。`)

列出当前空间中的所有表。

async listTables(): Promise<TableListItem[]>

示例:

const tables = await eidos.space.schema.listTables()
tables.forEach(t => console.log(`${t.name} (${t.id})`))

更新表元数据 (例如重命名)。

async updateTable(tableId: string, input: UpdateTableInput): Promise<TableInfo>

示例:

await eidos.space.schema.updateTable("table_id", { name: "新名称" })

永久删除一个表。

async deleteTable(tableId: string): Promise<boolean>

向现有表添加新字段。

async addField(tableId: string, input: CreateFieldInput): Promise<FieldInfo>

示例:

await eidos.space.schema.addField("table_id", {
name: "新字段",
columnName: "new_field",
type: "text"
})

更新现有字段的元数据。

async updateField(tableId: string, columnName: string, input: UpdateFieldInput): Promise<FieldInfo>

示例:

await eidos.space.schema.updateField("table_id", "priority", {
name: "任务优先级"
})

从表中删除字段。

async deleteField(tableId: string, columnName: string): Promise<boolean>

为表创建新视图。

async createView(tableId: string, input: CreateViewInput): Promise<ViewInfo>

示例:

await eidos.space.schema.createView("table_id", {
name: "我的看板",
type: "kanban"
})

列出与表关联的所有视图。

async listViews(tableId: string): Promise<ViewInfo[]>

删除特定视图。

async deleteView(tableId: string, viewId: string): Promise<boolean>