sql-ddl-to-json-schema
Version:
Parse and convert SQL DDL statements to a JSON Schema.
55 lines (54 loc) • 2.04 kB
TypeScript
import { O_CREATE_TABLE_CREATE_DEFINITION, P_CREATE_INDEX, O_CREATE_TABLE_CREATE_DEFINITION_SPATIAL_INDEX, O_ALTER_TABLE_SPEC_ADD_SPATIAL_INDEX, SpatialIndexInterface } from '../../../../typings';
import { SpatialIndexModelInterface, IndexColumnModelInterface, IndexOptionsModelInterface, TableModelInterface, ColumnModelInterface } from './typings';
/**
* Spatial index of a table.
*/
export declare class SpatialIndex implements SpatialIndexModelInterface {
name?: string;
columns: IndexColumnModelInterface[];
options?: IndexOptionsModelInterface;
/**
* Creates a spatial index from a JSON def.
*
* @param json JSON format parsed from SQL.
*/
static fromDef(json: O_CREATE_TABLE_CREATE_DEFINITION | P_CREATE_INDEX): SpatialIndex;
/**
* Creates a spatial index from an object containing needed properties.
*/
static fromObject(json: O_CREATE_TABLE_CREATE_DEFINITION_SPATIAL_INDEX | P_CREATE_INDEX['def'] | O_ALTER_TABLE_SPEC_ADD_SPATIAL_INDEX): SpatialIndex;
/**
* JSON casting of this object calls this method.
*/
toJSON(): SpatialIndexInterface;
/**
* Create a deep clone of this model.
*/
clone(): SpatialIndex;
/**
* Drops a column from index. Returns whether column was removed
*
* @param name Column name to be dropped.
*/
dropColumn(name: string): boolean;
/**
* Get the columns in given table which this
* spatial index's index columns refer to.
*
* @param table Table in question.
*/
getColumnsFromTable(table: TableModelInterface): ColumnModelInterface[];
/**
* Whether the given table has all of this spatial index's columns.
*
* @param table Table in question.
*/
hasAllColumnsFromTable(table: TableModelInterface): boolean;
/**
* Rename index column name.
*
* @param column Column being renamed.
* @param newName New column name.
*/
renameColumn(column: ColumnModelInterface, newName: string): void;
}