UNPKG

lakutata

Version:

An IoC-based universal application framework.

361 lines (351 loc) 8.7 kB
import './TypeDef.internal.30.js'; import { SelectQueryBuilder } from './TypeDef.internal.38.js'; import { DataSource } from './TypeDef.internal.33.js'; /** * Table's column options. */ interface TableColumnOptions { /** * Column name. */ name: string; /** * Column type. */ type: string; /** * Column's default value. */ default?: any; /** * ON UPDATE trigger. Works only for MySQL. */ onUpdate?: string; /** * Indicates if column is NULL, or is NOT NULL in the database. */ isNullable?: boolean; /** * Indicates if column is auto-generated sequence. */ isGenerated?: boolean; /** * Specifies generation strategy if this column will use auto increment. */ generationStrategy?: "uuid" | "increment" | "rowid" | "identity"; /** * Indicates if column is a primary key. */ isPrimary?: boolean; /** * Indicates if column has unique value. */ isUnique?: boolean; /** * Indicates if column stores array. */ isArray?: boolean; /** * Column's comment. */ comment?: string; /** * Column type's length. Used only on some column types. * For example type = "string" and length = "100" means that ORM will create a column with type varchar(100). */ length?: string; /** * Column type's display width. Used only on some column types in MySQL. * For example, INT(4) specifies an INT with a display width of four digits. */ width?: number; /** * Defines column character set. */ charset?: string; /** * Defines column collation. */ collation?: string; /** * The precision for a decimal (exact numeric) column (applies only for decimal column), which is the maximum * number of digits that are stored for the values. */ precision?: number | null; /** * The scale for a decimal (exact numeric) column (applies only for decimal column), which represents the number * of digits to the right of the decimal point and must not be greater than precision. */ scale?: number; /** * Puts ZEROFILL attribute on to numeric column. Works only for MySQL. * If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to the column */ zerofill?: boolean; /** * Puts UNSIGNED attribute on to numeric column. Works only for MySQL. */ unsigned?: boolean; /** * Array of possible enumerated values. */ enum?: string[]; /** * Exact name of enum */ enumName?: string; /** * If this column is primary key then this specifies the name for it. */ primaryKeyConstraintName?: string; /** * If this column is foreign key then this specifies the name for it. */ foreignKeyConstraintName?: string; /** * Generated column expression. */ asExpression?: string; /** * Generated column type. */ generatedType?: "VIRTUAL" | "STORED"; /** * Identity column type. Supports only in Postgres 10+. */ generatedIdentity?: "ALWAYS" | "BY DEFAULT"; /** * Spatial Feature Type (Geometry, Point, Polygon, etc.) */ spatialFeatureType?: string; /** * SRID (Spatial Reference ID (EPSG code)) */ srid?: number; } /** * View options. */ interface ViewOptions { /** * Database name that this table resides in if it applies. */ database?: string; /** * Schema name that this table resides in if it applies. */ schema?: string; /** * View name. */ name: string; /** * View expression. */ expression: string | ((connection: DataSource) => SelectQueryBuilder<any>); /** * Indicates if view is materialized */ materialized?: boolean; } /** * Foreign key options. */ interface TableForeignKeyOptions { /** * Name of the foreign key. */ name?: string; /** * Column names which included by this foreign key. */ columnNames: string[]; /** * Database of the Table referenced in the foreign key. */ referencedDatabase?: string; /** * Schema of the Table referenced in the foreign key. */ referencedSchema?: string; /** * Table referenced in the foreign key. */ referencedTableName: string; /** * Column names which included by this foreign key. */ referencedColumnNames: string[]; /** * "ON DELETE" of this foreign key, e.g. what action database should perform when * referenced stuff is being deleted. */ onDelete?: string; /** * "ON UPDATE" of this foreign key, e.g. what action database should perform when * referenced stuff is being updated. */ onUpdate?: string; /** * Set this foreign key constraint as "DEFERRABLE" e.g. check constraints at start * or at the end of a transaction */ deferrable?: string; } /** * Database's table unique constraint options. */ interface TableUniqueOptions { /** * Constraint name. */ name?: string; /** * Columns that contains this constraint. */ columnNames: string[]; /** * Set this foreign key constraint as "DEFERRABLE" e.g. check constraints at start * or at the end of a transaction */ deferrable?: string; } /** * Database's table check constraint options. */ interface TableCheckOptions { /** * Constraint name. */ name?: string; /** * Column that contains this constraint. */ columnNames?: string[]; /** * Check expression. */ expression?: string; } /** * Database's table exclusion constraint options. */ interface TableExclusionOptions { /** * Constraint name. */ name?: string; /** * Exclusion expression. */ expression?: string; } /** * Database's table index options. */ interface TableIndexOptions { /** * Constraint name. */ name?: string; /** * Columns included in this index. */ columnNames: string[]; /** * Indicates if this index is unique. */ isUnique?: boolean; /** * The SPATIAL modifier indexes the entire column and does not allow indexed columns to contain NULL values. * Works only in MySQL. */ isSpatial?: boolean; /** * Builds the index using the concurrently option. * This options is only supported for postgres database. */ isConcurrent?: boolean; /** * The FULLTEXT modifier indexes the entire column and does not allow prefixing. * Supported only in MySQL & SAP HANA. */ isFulltext?: boolean; /** * NULL_FILTERED indexes are particularly useful for indexing sparse columns, where most rows contain a NULL value. * In these cases, the NULL_FILTERED index can be considerably smaller and more efficient to maintain than * a normal index that includes NULL values. * * Works only in Spanner. */ isNullFiltered?: boolean; /** * Fulltext parser. * Works only in MySQL. */ parser?: string; /** * Index filter condition. */ where?: string; } /** * Table options. */ interface TableOptions { /** * Table schema. */ schema?: string; /** * Table database. */ database?: string; /** * Table name. */ name: string; /** * Table columns. */ columns?: TableColumnOptions[]; /** * Table indices. */ indices?: TableIndexOptions[]; /** * Table foreign keys. */ foreignKeys?: TableForeignKeyOptions[]; /** * Table unique constraints. */ uniques?: TableUniqueOptions[]; /** * Table check constraints. */ checks?: TableCheckOptions[]; /** * Table check constraints. */ exclusions?: TableExclusionOptions[]; /** * Indicates if table was just created. * This is needed, for example to check if we need to skip primary keys creation * for new tables. */ justCreated?: boolean; /** * Enables Sqlite "WITHOUT ROWID" modifier for the "CREATE TABLE" statement */ withoutRowid?: boolean; /** * Table engine. */ engine?: string; /** * Table comment. Not supported by all database types. */ comment?: string; } export type { TableCheckOptions, TableColumnOptions, TableExclusionOptions, TableForeignKeyOptions, TableIndexOptions, TableOptions, TableUniqueOptions, ViewOptions };