sql-ddl-to-json-schema
Version:
Parse and convert SQL DDL statements to a JSON Schema.
46 lines (45 loc) • 1.27 kB
TypeScript
import { P_DDS } from '../../../../typings';
import { DatabaseModelInterface, TableModelInterface } from './typings';
/**
* Database, which contains DDS array as its json.def.
* It is a formatter for MAIN parser rule.
*/
export declare class Database implements DatabaseModelInterface {
ddsCollection: P_DDS[];
tables: TableModelInterface[];
/**
* Get tables from parsed DDS array.
*/
getTables(): TableModelInterface[];
/**
* Setter for tables.
*
* @param tables Updated tables.
*/
setTables(tables: TableModelInterface[]): void;
/**
* Get table with given name.
*
* @param name Table name.
*/
getTable(name: string): TableModelInterface | undefined;
/**
* Pushes a table to database.
*
* @param table Table to be added.
*/
pushTable(table: TableModelInterface): void;
/**
* Build tables array from parsed DDL statements by sending them to
* appropriate handlers, updating tables array after each statement.
*
* @param ddsCollection DDS statements array.
*/
parseDdsCollection(ddsCollection: P_DDS[]): void;
/**
* Get statement handler from json id.
*
* @param id
*/
private static getHandler;
}