API 参考
    正在准备搜索索引...

    Driver organizes TypeORM communication with specific database management system.

    interface Driver {
        cteCapabilities: CteCapabilities;
        database?: string;
        dataTypeDefaults: DataTypeDefaults;
        dummyTableName?: string;
        isReplicated: boolean;
        mappedDataTypes: MappedColumnTypes;
        maxAliasLength?: number;
        options: BaseDataSourceOptions;
        parametersPrefix?: string;
        schema?: string;
        spatialTypes: ColumnType[];
        supportedDataTypes: ColumnType[];
        supportedOnDeleteTypes?: OnDeleteType[];
        supportedOnUpdateTypes?: OnUpdateType[];
        supportedUpsertTypes: UpsertType[];
        transactionSupport: "none" | "simple" | "nested";
        treeSupport: boolean;
        version?: string;
        withLengthColumnTypes: ColumnType[];
        withPrecisionColumnTypes: ColumnType[];
        withScaleColumnTypes: ColumnType[];
        afterConnect(): Promise<void>;
        buildTableName(
            tableName: string,
            schema?: string,
            database?: string,
        ): string;
        connect(): Promise<void>;
        createFullType(column: TableColumn): string;
        createGeneratedMap(
            metadata: EntityMetadata,
            insertResult: any,
            entityIndex?: number,
            entityNum?: number,
        ): undefined | ObjectLiteral;
        createParameter(parameterName: string, index: number): string;
        createQueryRunner(mode: ReplicationMode): QueryRunner;
        createSchemaBuilder(): SchemaBuilder;
        disconnect(): Promise<void>;
        escape(name: string): string;
        escapeQueryWithParameters(
            sql: string,
            parameters: ObjectLiteral,
            nativeParameters: ObjectLiteral,
        ): [string, any[]];
        findChangedColumns(
            tableColumns: TableColumn[],
            columnMetadatas: ColumnMetadata[],
        ): ColumnMetadata[];
        getColumnLength(column: ColumnMetadata): string;
        isFullTextColumnTypeSupported(): boolean;
        isReturningSqlSupported(returningType: ReturningType): boolean;
        isUUIDGenerationSupported(): boolean;
        normalizeDefault(columnMetadata: ColumnMetadata): undefined | string;
        normalizeIsUnique(column: ColumnMetadata): boolean;
        normalizeType(
            column: {
                isArray?: boolean;
                length?: string | number;
                precision?: null | number;
                scale?: number;
                type?:
                    | string
                    | BooleanConstructor
                    | DateConstructor
                    | NumberConstructor
                    | StringConstructor;
            },
        ): string;
        obtainMasterConnection(): Promise<any>;
        obtainSlaveConnection(): Promise<any>;
        parseTableName(
            target: string | EntityMetadata | TableForeignKey | Table | View,
        ): { database?: string; schema?: string; tableName: string };
        prepareHydratedValue(value: any, column: ColumnMetadata): any;
        preparePersistentValue(value: any, column: ColumnMetadata): any;
    }
    索引

    属性

    cteCapabilities: CteCapabilities
    database?: string

    Database name used to perform all write queries.

    todo: probably move into query runner.

    dataTypeDefaults: DataTypeDefaults

    Default values of length, precision and scale depends on column data type. Used in the cases when length/precision/scale is not specified by user.

    dummyTableName?: string

    Dummy table name

    isReplicated: boolean

    Indicates if replication is enabled.

    mappedDataTypes: MappedColumnTypes

    Orm has special columns and we need to know what database column types should be for those types. Column types are driver dependant.

    maxAliasLength?: number

    Max length allowed by the DBMS for aliases (execution of queries).

    options: BaseDataSourceOptions

    Connection options.

    parametersPrefix?: string

    The prefix used for the parameters

    schema?: string

    Schema name used to perform all write queries.

    spatialTypes: ColumnType[]

    Gets list of spatial column data types.

    supportedDataTypes: ColumnType[]

    Gets list of supported column data types by a driver.

    supportedOnDeleteTypes?: OnDeleteType[]

    Returns list of supported onDelete types by driver

    supportedOnUpdateTypes?: OnUpdateType[]

    Returns list of supported onUpdate types by driver

    supportedUpsertTypes: UpsertType[]

    Returns type of upsert supported by driver if any

    transactionSupport: "none" | "simple" | "nested"

    Represent transaction support by this driver

    treeSupport: boolean

    Indicates if tree tables are supported by this driver.

    version?: string

    Database version/release. Often requires a SQL query to the DB, so it is not always set

    withLengthColumnTypes: ColumnType[]

    Gets list of column data types that support length by a driver.

    withPrecisionColumnTypes: ColumnType[]

    Gets list of column data types that support precision by a driver.

    withScaleColumnTypes: ColumnType[]

    Gets list of column data types that support scale by a driver.

    方法

    • Makes any action after connection (e.g. create extensions in Postgres driver).

      返回 Promise<void>

    • Build full table name with database name, schema name and table name. E.g. myDB.mySchema.myTable

      参数

      • tableName: string
      • 可选schema: string
      • 可选database: string

      返回 string

    • Performs connection to the database. Depend on driver type it may create a connection pool.

      返回 Promise<void>

    • Normalizes "default" value of the column.

      参数

      返回 string

    • Creates generated map of values generated or returned by database after INSERT query.

      参数

      • metadata: EntityMetadata
      • insertResult: any
      • 可选entityIndex: number
      • 可选entityNum: number

      返回 undefined | ObjectLiteral

    • Creates an escaped parameter.

      参数

      • parameterName: string
      • index: number

      返回 string

    • Creates a query runner used for common queries.

      参数

      返回 QueryRunner

    • Synchronizes database schema (creates tables, indices, etc).

      返回 SchemaBuilder

    • Closes connection with database and releases all resources.

      返回 Promise<void>

    • Escapes a table name, column name or an alias.

      todo: probably escape should be able to handle dots in the names and automatically escape them

      参数

      • name: string

      返回 string

    • Replaces parameters in the given sql with special escaping character and an array of parameter names to be passed to a query.

      参数

      返回 [string, any[]]

    • Differentiate columns of this table and columns from the given column metadatas columns and returns only changed.

      参数

      • tableColumns: TableColumn[]
      • columnMetadatas: ColumnMetadata[]

      返回 ColumnMetadata[]

    • Calculates column length taking into account the default length values.

      参数

      • column: ColumnMetadata

      返回 string

    • Returns true if driver supports fulltext indices.

      返回 boolean

    • Returns true if driver supports RETURNING / OUTPUT statement.

      参数

      • returningType: ReturningType

      返回 boolean

    • Returns true if driver supports uuid values generation on its own.

      返回 boolean

    • Normalizes "default" value of the column.

      参数

      • columnMetadata: ColumnMetadata

      返回 undefined | string

    • Normalizes "isUnique" value of the column.

      参数

      • column: ColumnMetadata

      返回 boolean

    • Transforms type of the given column to a database column type.

      参数

      • column: {
            isArray?: boolean;
            length?: string | number;
            precision?: null | number;
            scale?: number;
            type?:
                | string
                | BooleanConstructor
                | DateConstructor
                | NumberConstructor
                | StringConstructor;
        }

      返回 string

    • Obtains a new database connection to a master server. Used for replication. If replication is not setup then returns default connection's database connection.

      返回 Promise<any>

    • Obtains a new database connection to a slave server. Used for replication. If replication is not setup then returns master (default) connection's database connection.

      返回 Promise<any>

    • Parse a target table name or other types and return a normalized table definition.

      参数

      返回 { database?: string; schema?: string; tableName: string }

    • Prepares given value to a value to be persisted, based on its column type.

      参数

      • value: any
      • column: ColumnMetadata

      返回 any

    • Prepares given value to a value to be persisted, based on its column type and metadata.

      参数

      • value: any
      • column: ColumnMetadata

      返回 any