typeorm
Version:
Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, WebSQL, MongoDB databases.
164 lines (163 loc) • 6 kB
TypeScript
import { Driver } from "../Driver";
import { SqlServerQueryRunner } from "./SqlServerQueryRunner";
import { ObjectLiteral } from "../../common/ObjectLiteral";
import { ColumnMetadata } from "../../metadata/ColumnMetadata";
import { Connection } from "../../connection/Connection";
import { RdbmsSchemaBuilder } from "../../schema-builder/RdbmsSchemaBuilder";
import { SqlServerConnectionOptions } from "./SqlServerConnectionOptions";
import { MappedColumnTypes } from "../types/MappedColumnTypes";
import { ColumnType } from "../types/ColumnTypes";
import { DataTypeDefaults } from "../types/DataTypeDefaults";
import { MssqlParameter } from "./MssqlParameter";
import { TableColumn } from "../../schema-builder/schema/TableColumn";
import { SqlServerConnectionCredentialsOptions } from "./SqlServerConnectionCredentialsOptions";
/**
* Organizes communication with SQL Server DBMS.
*/
export declare class SqlServerDriver implements Driver {
/**
* Connection used by driver.
*/
connection: Connection;
/**
* SQL Server library.
*/
mssql: any;
/**
* Pool for master database.
*/
master: any;
/**
* Pool for slave databases.
* Used in replication.
*/
slaves: any[];
/**
* Connection options.
*/
options: SqlServerConnectionOptions;
/**
* Master database used to perform all write queries.
*/
database?: string;
/**
* Indicates if replication is enabled.
*/
isReplicated: boolean;
/**
* Indicates if tree tables are supported by this driver.
*/
treeSupport: boolean;
/**
* Gets list of supported column data types by a driver.
*
* @see https://docs.microsoft.com/en-us/sql/t-sql/data-types/data-types-transact-sql
*/
supportedDataTypes: ColumnType[];
/**
* Gets list of column data types that support length by a driver.
*/
withLengthColumnTypes: ColumnType[];
/**
* Orm has special columns and we need to know what database column types should be for those types.
* Column types are driver dependant.
*/
mappedDataTypes: MappedColumnTypes;
/**
* 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.
*/
dataTypeDefaults: DataTypeDefaults;
constructor(connection: Connection);
/**
* Performs connection to the database.
* Based on pooling options, it can either create connection immediately,
* either create a pool and create connection when needed.
*/
connect(): Promise<void>;
/**
* Makes any action after connection (e.g. create extensions in Postgres driver).
*/
afterConnect(): Promise<void>;
/**
* Closes connection with the database.
*/
disconnect(): Promise<void>;
/**
* Creates a schema builder used to build and sync a schema.
*/
createSchemaBuilder(): RdbmsSchemaBuilder;
/**
* Creates a query runner used to execute database queries.
*/
createQueryRunner(mode?: "master" | "slave"): SqlServerQueryRunner;
/**
* Replaces parameters in the given sql with special escaping character
* and an array of parameter names to be passed to a query.
*/
escapeQueryWithParameters(sql: string, parameters: ObjectLiteral): [string, any[]];
/**
* Escapes a column name.
*/
escape(columnName: string): string;
/**
* Prepares given value to a value to be persisted, based on its column type and metadata.
*/
preparePersistentValue(value: any, columnMetadata: ColumnMetadata): any;
/**
* Prepares given value to a value to be persisted, based on its column type or metadata.
*/
prepareHydratedValue(value: any, columnMetadata: ColumnMetadata): any;
/**
* Creates a database type from a given column metadata.
*/
normalizeType(column: {
type?: ColumnType;
length?: number | string;
precision?: number;
scale?: number;
}): string;
/**
* Normalizes "default" value of the column.
*/
normalizeDefault(column: ColumnMetadata): string;
/**
* Normalizes "isUnique" value of the column.
*/
normalizeIsUnique(column: ColumnMetadata): boolean;
/**
* Calculates column length taking into account the default length values.
*/
getColumnLength(column: ColumnMetadata): string;
createFullType(column: TableColumn): 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.
*/
obtainMasterConnection(): 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.
*/
obtainSlaveConnection(): Promise<any>;
/**
* Sql server's parameters needs to be wrapped into special object with type information about this value.
* This method wraps given value into MssqlParameter based on its column definition.
*/
parametrizeValue(column: ColumnMetadata, value: any): MssqlParameter;
/**
* Sql server's parameters needs to be wrapped into special object with type information about this value.
* This method wraps all values of the given object into MssqlParameter based on their column definitions in the given table.
*/
parametrizeMap(tablePath: string, map: ObjectLiteral): ObjectLiteral;
/**
* If driver dependency is not given explicitly, then try to load it via "require".
*/
protected loadDependencies(): void;
/**
* Creates a new connection pool for a given database credentials.
*/
protected createPool(options: SqlServerConnectionOptions, credentials: SqlServerConnectionCredentialsOptions): Promise<any>;
}