diff --git a/src/index.ts b/src/index.ts index bad92fc..059d650 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import { tableToTS } from './typescript' +import { tableToTS, Table } from './typescript' import { MySQL } from './mysql-client' import prettier from 'prettier' import pkg from '../package.json' @@ -42,3 +42,14 @@ export async function inferSchema(connectionString: string): Promise { const code = [header(interfaces.some(i => i.includes('JSON'))), ...interfaces].join('\n') return pretty(code) } + +export async function inferTableObject(connectionString: string, table: string): Promise { + const db = new MySQL(connectionString) + return db.table(table) +} + +export async function inferSchemaObject(connectionString: string) { + const db = new MySQL(connectionString) + const tables = await db.allTables() + return tables +}