UNPKG

1.37 kBTypeScriptView Raw
1import * as Knex from "knex";
2import { IDatabaseSchema } from "./mysql-database-definition";
3export default class ModelBuilder {
4 private knex;
5 private databaseName?;
6 static init(knex: Knex): Promise<IDatabaseSchema>;
7 /**
8 * Return a copy of an object but with all keys lower case
9 */
10 private static keysToLower;
11 /**
12 * Return the length of a type, eg varchar(255)=>255
13 * 0 if not parsable
14 * @param type
15 */
16 private static getMysqlLength;
17 /**
18 * Return the length of a type, eg varchar(255)=>varchar
19 * @param type
20 */
21 private static stripMysqlLength;
22 private static getEnumValues;
23 constructor(knex: Knex, databaseName?: string | undefined);
24 renderDatabaseSchema(): Promise<IDatabaseSchema>;
25 private getDatabaseName;
26 /**
27 * return a select query to list all tables or views from a database
28 */
29 private listFromDatabase;
30 private listViews;
31 /**
32 * Lists all the tables in current database
33 */
34 private listTables;
35 private columnArrayToDatabaseSchema;
36 /**
37 * List all columns for a table given table name
38 */
39 private listColumns;
40 private renderModel;
41 private listStoredProcedures;
42 private listStoredProcedureParams;
43 private renderStoredProcedures;
44 private renderViewModel;
45 private renderTableModel;
46}