Skip to content

Commit

Permalink
Expose inferSchemaObject and inferTableObject
Browse files Browse the repository at this point in the history
  • Loading branch information
nettofarah committed Jan 14, 2020
1 parent 0e7f403 commit 7c91f7a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -42,3 +42,14 @@ export async function inferSchema(connectionString: string): Promise<string> {
const code = [header(interfaces.some(i => i.includes('JSON'))), ...interfaces].join('\n')
return pretty(code)
}

export async function inferTableObject(connectionString: string, table: string): Promise<Table> {
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
}

0 comments on commit 7c91f7a

Please sign in to comment.