106 lines
3.2 KiB
TypeScript
106 lines
3.2 KiB
TypeScript
import {
|
|
type Configuration,
|
|
type DeferMode,
|
|
type Dictionary,
|
|
type EntityMetadata,
|
|
type EntityProperty,
|
|
type IndexCallback,
|
|
type NamingStrategy,
|
|
} from '@mikro-orm/core';
|
|
import type { SchemaHelper } from './SchemaHelper.js';
|
|
import type { CheckDef, Column, ForeignKey, IndexDef } from '../typings.js';
|
|
import type { AbstractSqlPlatform } from '../AbstractSqlPlatform.js';
|
|
/**
|
|
* @internal
|
|
*/
|
|
export declare class DatabaseTable {
|
|
#private;
|
|
readonly name: string;
|
|
readonly schema?: string | undefined;
|
|
nativeEnums: Dictionary<{
|
|
name: string;
|
|
schema?: string;
|
|
items: string[];
|
|
}>;
|
|
comment?: string;
|
|
constructor(platform: AbstractSqlPlatform, name: string, schema?: string | undefined);
|
|
getQuotedName(): string;
|
|
getColumns(): Column[];
|
|
getColumn(name: string): Column | undefined;
|
|
removeColumn(name: string): void;
|
|
getIndexes(): IndexDef[];
|
|
getChecks(): CheckDef[];
|
|
/** @internal */
|
|
setIndexes(indexes: IndexDef[]): void;
|
|
/** @internal */
|
|
setChecks(checks: CheckDef[]): void;
|
|
/** @internal */
|
|
setForeignKeys(fks: Dictionary<ForeignKey>): void;
|
|
init(
|
|
cols: Column[],
|
|
indexes: IndexDef[] | undefined,
|
|
checks: CheckDef[] | undefined,
|
|
pks: string[],
|
|
fks?: Dictionary<ForeignKey>,
|
|
enums?: Dictionary<string[]>,
|
|
): void;
|
|
addColumn(column: Column): void;
|
|
addColumnFromProperty(prop: EntityProperty, meta: EntityMetadata, config: Configuration): void;
|
|
private getIndexName;
|
|
getEntityDeclaration(
|
|
namingStrategy: NamingStrategy,
|
|
schemaHelper: SchemaHelper,
|
|
scalarPropertiesForRelations: 'always' | 'never' | 'smart',
|
|
): EntityMetadata;
|
|
private foreignKeysToProps;
|
|
private findFkIndex;
|
|
private getIndexProperties;
|
|
private getSafeBaseNameForFkProp;
|
|
/**
|
|
* The shortest name is stripped of the default namespace. All other namespaced elements are returned as full-qualified names.
|
|
*/
|
|
getShortestName(skipDefaultSchema?: boolean): string;
|
|
getForeignKeys(): Dictionary<ForeignKey>;
|
|
hasColumn(columnName: string): boolean;
|
|
getIndex(indexName: string): IndexDef | undefined;
|
|
hasIndex(indexName: string): boolean;
|
|
getCheck(checkName: string): CheckDef | undefined;
|
|
hasCheck(checkName: string): boolean;
|
|
getPrimaryKey(): IndexDef | undefined;
|
|
hasPrimaryKey(): boolean;
|
|
private getForeignKeyDeclaration;
|
|
private getPropertyDeclaration;
|
|
private getReferenceKind;
|
|
private getPropertyName;
|
|
private getPropertyTypeForForeignKey;
|
|
private getPropertyTypeForColumn;
|
|
private getPropertyDefaultValue;
|
|
private processIndexExpression;
|
|
addIndex(
|
|
meta: EntityMetadata,
|
|
index: {
|
|
properties?: string | string[];
|
|
name?: string;
|
|
type?: string;
|
|
expression?: string | IndexCallback<any>;
|
|
deferMode?: DeferMode | `${DeferMode}`;
|
|
options?: Dictionary;
|
|
columns?: {
|
|
name: string;
|
|
sort?: 'ASC' | 'DESC' | 'asc' | 'desc';
|
|
nulls?: 'FIRST' | 'LAST' | 'first' | 'last';
|
|
length?: number;
|
|
collation?: string;
|
|
}[];
|
|
include?: string | string[];
|
|
fillFactor?: number;
|
|
invisible?: boolean;
|
|
disabled?: boolean;
|
|
clustered?: boolean;
|
|
},
|
|
type: 'index' | 'unique' | 'primary',
|
|
): void;
|
|
addCheck(check: CheckDef): void;
|
|
toJSON(): Dictionary;
|
|
}
|