MCPcopy Create free account
hub / github.com/outerbase/studio / view

Method view

src/drivers/postgres/postgres-driver.ts:411–425  ·  view source on GitHub ↗
(schemaName: string, name: string)

Source from the content-addressed store, hash-verified

409 }
410
411 async view(schemaName: string, name: string): Promise<DatabaseViewSchema> {
412 const sql = `SELECT * FROM information_schema.views WHERE TABLE_SCHEMA=${this.escapeValue(schemaName)} AND TABLE_NAME=${this.escapeValue(name)}`;
413 const result = await this.query(sql);
414
415 const viewRow = result.rows[0] as { view_definition: string } | undefined;
416 if (!viewRow) throw new Error("View dose not exist");
417
418 const statement = viewRow.view_definition.trim();
419
420 return {
421 schemaName,
422 name,
423 statement,
424 };
425 }
426
427 createView(view: DatabaseViewSchema): string {
428 return `CREATE VIEW ${this.escapeId(view.schemaName)}.${this.escapeId(view.name)} AS ${view.statement}`;

Callers

nothing calls this directly

Calls 2

escapeValueMethod · 0.95
queryMethod · 0.95

Tested by

no test coverage detected