MCPcopy
hub / github.com/mayneyao/eidos / createTableViaSchema

Method createTableViaSchema

packages/core/data-space/table.ts:349–368  ·  view source on GitHub ↗
(
    id: string,
    name: string,
    tableSchema: string,
    parent_id?: string
  )

Source from the content-addressed store, hash-verified

347 }
348
349 public async createTableViaSchema(
350 id: string,
351 name: string,
352 tableSchema: string,
353 parent_id?: string
354 ) {
355 // FIXME: should use db transaction to execute multiple sql
356
357 try {
358 await this.db.prepare("BEGIN TRANSACTION;").run()
359 await this.tree.addNode({ id, name, type: TreeNodeType.Table, parent_id })
360 await this.db.exec(tableSchema)
361 // create view for table
362 await this.view.createDefaultView(getRawTableNameById(id))
363 await this.db.prepare("COMMIT;").run()
364 } catch (error) {
365 await this.db.prepare("ROLLBACK;").run()
366 throw error
367 }
368 }
369
370 public async fixTable(tableId: string) {
371 const tableManager = this._table(tableId)

Callers 5

createTableMethod · 0.95
importMethod · 0.80
createMethod · 0.80
createTableMethod · 0.80
createTableAndRegisterFunction · 0.80

Calls 6

getRawTableNameByIdFunction · 0.90
addNodeMethod · 0.80
createDefaultViewMethod · 0.80
runMethod · 0.65
prepareMethod · 0.65
execMethod · 0.65

Tested by

no test coverage detected