mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
refactored connection manager and connection option classes
This commit is contained in:
parent
7b99e82938
commit
dc976f4d27
@ -1,10 +1,10 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
@ -16,7 +16,7 @@ const options: CreateConnectionOptions = {
|
||||
};
|
||||
/*const options: CreateConnectionOptions = {
|
||||
driver: "postgres",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 5432,
|
||||
username: "test",
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
import {PostDetails} from "./entity/PostDetails";
|
||||
import {Image} from "./entity/Image";
|
||||
import {Cover} from "./entity/Cover";
|
||||
import {Category} from "./entity/Category";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {EverythingEntity} from "./entity/EverythingEntity";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
import {CustomNamingStrategy} from "./naming-strategy/CustomNamingStrategy";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
import {PostCategory} from "./entity/PostCategory";
|
||||
import {PostAuthor} from "./entity/PostAuthor";
|
||||
import {Blog} from "./entity/Blog";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import "reflect-metadata";
|
||||
import {CreateConnectionOptions, createConnection} from "../../src/index";
|
||||
import {ConnectionOptions, createConnection} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
import {PostAuthor} from "./entity/PostAuthor";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
import {Author} from "./entity/Author";
|
||||
import {Category} from "./entity/Category";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
import {Author} from "./entity/Author";
|
||||
import {Category} from "./entity/Category";
|
||||
import {PostMetadata} from "./entity/PostMetadata";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import "reflect-metadata";
|
||||
import {CreateConnectionOptions, createConnection} from "../../src/index";
|
||||
import {ConnectionOptions, createConnection} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
import {PostDetails} from "./entity/PostDetails";
|
||||
import {PostCategory} from "./entity/PostCategory";
|
||||
@ -8,9 +8,9 @@ import {PostImage} from "./entity/PostImage";
|
||||
import {PostInformation} from "./entity/PostInformation";
|
||||
import {PostAuthor} from "./entity/PostAuthor";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
import {Author} from "./entity/Author";
|
||||
import {Category} from "./entity/Category";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
import {Author} from "./entity/Author";
|
||||
import {Category} from "./entity/Category";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Category} from "./entity/Category";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
import {Author} from "./entity/Author";
|
||||
import {Category} from "./entity/Category";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
|
||||
// NOTE: this example is not working yet, only concepts of how this feature must work described here
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
import {Author} from "./entity/Author";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
import {Question} from "./entity/Question";
|
||||
import {Counters} from "./entity/Counters";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import "reflect-metadata";
|
||||
import {CreateConnectionOptions, createConnection} from "../../src/index";
|
||||
import {ConnectionOptions, createConnection} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
import {PostDetails} from "./entity/PostDetails";
|
||||
import {PostCategory} from "./entity/PostCategory";
|
||||
@ -8,9 +8,9 @@ import {PostImage} from "./entity/PostImage";
|
||||
import {PostInformation} from "./entity/PostInformation";
|
||||
import {PostAuthor} from "./entity/PostAuthor";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import "reflect-metadata";
|
||||
import {CreateConnectionOptions, createConnection} from "../../src/index";
|
||||
import {ConnectionOptions, createConnection} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
import {PostDetails} from "./entity/PostDetails";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
import {PostCategory} from "./entity/PostCategory";
|
||||
import {PostAuthor} from "./entity/PostAuthor";
|
||||
import {EverythingSubscriber} from "./subscriber/EverythingSubscriber";
|
||||
|
||||
// first create a connection
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
import {PostCategory} from "./entity/PostCategory";
|
||||
import {PostAuthor} from "./entity/PostAuthor";
|
||||
import {Blog} from "./entity/Blog";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
import {PostCategory} from "./entity/PostCategory";
|
||||
import {PostAuthor} from "./entity/PostAuthor";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import "reflect-metadata";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Category} from "./entity/Category";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import "reflect-metadata";
|
||||
import {CreateConnectionOptions, createConnection} from "../../src/index";
|
||||
import {ConnectionOptions, createConnection} from "../../src/index";
|
||||
import {Post} from "./entity/Post";
|
||||
import {PostCategory} from "./entity/PostCategory";
|
||||
import {PostAuthor} from "./entity/PostAuthor";
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Used to mark simple objects with any string keys.
|
||||
* Interface of the simple literal object with any string keys.
|
||||
*/
|
||||
export interface ObjectLiteral {
|
||||
[key: string]: any;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Used to get a type of the creating Function.
|
||||
* Represents some Type of the Object.
|
||||
*/
|
||||
export interface ObjectType<T> {
|
||||
new (): T;
|
||||
|
||||
@ -37,7 +37,7 @@ import {EntityMetadata} from "../metadata/EntityMetadata";
|
||||
|
||||
/**
|
||||
* A single connection instance to the database.
|
||||
* Each connection has its own entity manager, repositories, subscribers and metadatas.
|
||||
* Each connection has its own entity manager, repositories, broadcaster and entity metadatas.
|
||||
*/
|
||||
export class Connection {
|
||||
|
||||
@ -46,7 +46,7 @@ export class Connection {
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The name of the connection.
|
||||
* Connection name.
|
||||
*/
|
||||
public readonly name: string;
|
||||
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import {Connection} from "./Connection";
|
||||
import {ConnectionNotFoundError} from "./error/ConnectionNotFoundError";
|
||||
import {MysqlDriver} from "../driver/MysqlDriver";
|
||||
import {CreateConnectionOptions} from "./CreateConnectionOptions";
|
||||
import {ConnectionOptions} from "../driver/ConnectionOptions";
|
||||
import {ConnectionOptions} from "./ConnectionOptions";
|
||||
import {DriverOptions} from "../driver/DriverOptions";
|
||||
import {Driver} from "../driver/Driver";
|
||||
import {MissingDriverError} from "./error/MissingDriverError";
|
||||
import {PostgresDriver} from "../driver/PostgresDriver";
|
||||
import {AlreadyHasActiveConnectionError} from "./error/AlreadyHasActiveConnectionError";
|
||||
|
||||
/**
|
||||
* Connection manager holds all connections made to the databases and providers helper management functions
|
||||
@ -17,6 +18,9 @@ export class ConnectionManager {
|
||||
// Properties
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* List of connections registered in this connection manager.
|
||||
*/
|
||||
private connections: Connection[] = [];
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -24,10 +28,10 @@ export class ConnectionManager {
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Creates a new connection based on the given connection options and registers a new connection in the manager.
|
||||
* Creates a new connection based on the given connection options and registers this connection in the manager.
|
||||
*/
|
||||
create(options: CreateConnectionOptions): Connection {
|
||||
const driver = this.createDriver(options.driver, options.connection);
|
||||
create(options: ConnectionOptions): Connection {
|
||||
const driver = this.createDriver(options.driver, options.driverOptions);
|
||||
const connection = this.createConnection(options.connectionName || "default", driver);
|
||||
|
||||
if (options.entitySchemaDirectories && options.entitySchemaDirectories.length > 0)
|
||||
@ -66,7 +70,7 @@ export class ConnectionManager {
|
||||
/**
|
||||
* Creates a new connection based on the given connection options and registers a new connection in the manager.
|
||||
*/
|
||||
async createAndConnect(options: CreateConnectionOptions): Promise<Connection> {
|
||||
async createAndConnect(options: ConnectionOptions): Promise<Connection> {
|
||||
const connection = this.create(options);
|
||||
|
||||
// connect to the database
|
||||
@ -84,12 +88,16 @@ export class ConnectionManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new connection and pushes a connection to the array.
|
||||
* Creates a new connection and registers it in the connection manager.
|
||||
*/
|
||||
createConnection(name: string, driver: Driver) {
|
||||
const existConnection = this.connections.find(connection => connection.name === name);
|
||||
if (existConnection)
|
||||
if (existConnection) {
|
||||
if (existConnection.isConnected)
|
||||
throw new AlreadyHasActiveConnectionError(name);
|
||||
|
||||
this.connections.splice(this.connections.indexOf(existConnection), 1);
|
||||
}
|
||||
|
||||
const connection = new Connection(name, driver);
|
||||
this.connections.push(connection);
|
||||
@ -97,12 +105,10 @@ export class ConnectionManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets registered connection with the given name. If connection name is not given then it will get a default
|
||||
* connection.
|
||||
* Gets registered connection with the given name.
|
||||
* If connection name is not given then it will get a default connection.
|
||||
*/
|
||||
get(name: string = "default"): Connection {
|
||||
if (!name) name = "default";
|
||||
|
||||
const connection = this.connections.find(connection => connection.name === name);
|
||||
if (!connection)
|
||||
throw new ConnectionNotFoundError(name);
|
||||
@ -114,14 +120,17 @@ export class ConnectionManager {
|
||||
// Private Methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
private createDriver(driverName: string, options: ConnectionOptions): Driver {
|
||||
switch (driverName) {
|
||||
/**
|
||||
* Creates a new driver based on the given driver type and options.
|
||||
*/
|
||||
private createDriver(driverType: "mysql"|"postgres", options: DriverOptions): Driver {
|
||||
switch (driverType) {
|
||||
case "mysql":
|
||||
return new MysqlDriver(options);
|
||||
case "postgres":
|
||||
return new PostgresDriver(options);
|
||||
default:
|
||||
throw new MissingDriverError(driverName);
|
||||
throw new MissingDriverError(driverType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import {ConnectionOptions} from "../driver/ConnectionOptions";
|
||||
import {DriverOptions} from "../driver/DriverOptions";
|
||||
import {EntitySchema} from "../metadata/entity-schema/EntitySchema";
|
||||
|
||||
/**
|
||||
* All options to help to create a new connection.
|
||||
* New connection options.
|
||||
*/
|
||||
export interface CreateConnectionOptions {
|
||||
export interface ConnectionOptions {
|
||||
|
||||
/**
|
||||
* Driver type. Mysql and postgres are the only drivers supported at this moment.
|
||||
@ -14,7 +14,7 @@ export interface CreateConnectionOptions {
|
||||
/**
|
||||
* Database connection options.
|
||||
*/
|
||||
connection: ConnectionOptions;
|
||||
driverOptions: DriverOptions;
|
||||
|
||||
/**
|
||||
* Connection name. By default its called "default". Different connections must have different names.
|
||||
12
src/connection/error/AlreadyHasActiveConnectionError.ts
Normal file
12
src/connection/error/AlreadyHasActiveConnectionError.ts
Normal file
@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class AlreadyHasActiveConnectionError extends Error {
|
||||
name = "AlreadyHasActiveConnectionError";
|
||||
|
||||
constructor(connectionName: string) {
|
||||
super();
|
||||
this.message = `Cannot create a new connection named "${connectionName}", because connection with such name already exist and it now has an active connection session.`;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
import {ConnectionOptions} from "./ConnectionOptions";
|
||||
import {DriverOptions} from "./DriverOptions";
|
||||
import {ColumnMetadata} from "../metadata/ColumnMetadata";
|
||||
import {ColumnTypes} from "../metadata/types/ColumnTypes";
|
||||
import * as moment from "moment";
|
||||
@ -13,7 +13,7 @@ export abstract class BaseDriver {
|
||||
// Properties
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
abstract connectionOptions: ConnectionOptions;
|
||||
abstract connectionOptions: DriverOptions;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Private Properties
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import {SchemaBuilder} from "../schema-builder/SchemaBuilder";
|
||||
import {ColumnMetadata} from "../metadata/ColumnMetadata";
|
||||
import {ConnectionOptions} from "./ConnectionOptions";
|
||||
import {DriverOptions} from "./DriverOptions";
|
||||
import {ObjectLiteral} from "../common/ObjectLiteral";
|
||||
|
||||
/**
|
||||
@ -21,7 +21,7 @@ export interface Driver {
|
||||
/**
|
||||
* Connection options used in this driver.
|
||||
*/
|
||||
connectionOptions: ConnectionOptions;
|
||||
connectionOptions: DriverOptions;
|
||||
|
||||
/**
|
||||
* Database name to which this connection is made.
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Connection options passed to the driver.
|
||||
* Driver connection options.
|
||||
*/
|
||||
export interface ConnectionOptions {
|
||||
export interface DriverOptions {
|
||||
|
||||
/**
|
||||
* Url to where perform connection.
|
||||
@ -34,7 +34,7 @@ export interface ConnectionOptions {
|
||||
database?: string;
|
||||
|
||||
/**
|
||||
* Logging options.
|
||||
* Driver logging options.
|
||||
*/
|
||||
logging?: {
|
||||
|
||||
@ -6,7 +6,7 @@ import {BaseDriver} from "./BaseDriver";
|
||||
import {ColumnMetadata} from "../metadata/ColumnMetadata";
|
||||
import {ColumnTypes} from "../metadata/types/ColumnTypes";
|
||||
import * as moment from "moment";
|
||||
import {ConnectionOptions} from "./ConnectionOptions";
|
||||
import {DriverOptions} from "./DriverOptions";
|
||||
import {ObjectLiteral} from "../common/ObjectLiteral";
|
||||
|
||||
/**
|
||||
@ -70,7 +70,7 @@ export class MysqlDriver extends BaseDriver implements Driver {
|
||||
// Constructor
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
constructor(public connectionOptions: ConnectionOptions, mysql?: any) {
|
||||
constructor(public connectionOptions: DriverOptions, mysql?: any) {
|
||||
super();
|
||||
|
||||
// if driver dependency is not given explicitly, then try to load it via "require"
|
||||
|
||||
@ -2,7 +2,7 @@ import {Driver} from "./Driver";
|
||||
import {SchemaBuilder} from "../schema-builder/SchemaBuilder";
|
||||
import {ConnectionIsNotSetError} from "./error/ConnectionIsNotSetError";
|
||||
import {BaseDriver} from "./BaseDriver";
|
||||
import {ConnectionOptions} from "./ConnectionOptions";
|
||||
import {DriverOptions} from "./DriverOptions";
|
||||
import {PostgresSchemaBuilder} from "../schema-builder/PostgresSchemaBuilder";
|
||||
import {ObjectLiteral} from "../common/ObjectLiteral";
|
||||
|
||||
@ -67,7 +67,7 @@ export class PostgresDriver extends BaseDriver implements Driver {
|
||||
// Constructor
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
constructor(public connectionOptions: ConnectionOptions, postgres?: any) {
|
||||
constructor(public connectionOptions: DriverOptions, postgres?: any) {
|
||||
super();
|
||||
|
||||
// if driver dependency is not given explicitly, then try to load it via "require"
|
||||
|
||||
10
src/index.ts
10
src/index.ts
@ -2,12 +2,12 @@
|
||||
|
||||
*/
|
||||
|
||||
import {ConnectionOptions} from "./driver/ConnectionOptions";
|
||||
import {DriverOptions} from "./driver/DriverOptions";
|
||||
import {ConnectionManager} from "./connection/ConnectionManager";
|
||||
import {Connection} from "./connection/Connection";
|
||||
import {MysqlDriver} from "./driver/MysqlDriver";
|
||||
import {MetadataArgsStorage} from "./metadata-args/MetadataArgsStorage";
|
||||
import {CreateConnectionOptions} from "./connection/CreateConnectionOptions";
|
||||
import {ConnectionOptions} from "./connection/ConnectionOptions";
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Global Container
|
||||
@ -92,7 +92,7 @@ export function getConnectionManager() {
|
||||
/**
|
||||
* Allows to quickly create a connection based on the given options. Uses ConnectionManager.
|
||||
*/
|
||||
export function createConnection(options: CreateConnectionOptions) {
|
||||
export function createConnection(options: ConnectionOptions) {
|
||||
return getConnectionManager().createAndConnect(options);
|
||||
}
|
||||
|
||||
@ -101,9 +101,9 @@ export function createConnection(options: CreateConnectionOptions) {
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
export {Connection} from "./connection/Connection";
|
||||
export {ConnectionOptions} from "./driver/ConnectionOptions";
|
||||
export {DriverOptions} from "./driver/DriverOptions";
|
||||
export {ConnectionManager} from "./connection/ConnectionManager";
|
||||
export {CreateConnectionOptions} from "./connection/CreateConnectionOptions";
|
||||
export {ConnectionOptions} from "./connection/ConnectionOptions";
|
||||
export {Driver} from "./driver/Driver";
|
||||
export {MysqlDriver} from "./driver/MysqlDriver";
|
||||
export {QueryBuilder} from "./query-builder/QueryBuilder";
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import {QueryBuilder} from "../query-builder/QueryBuilder";
|
||||
import {ConnectionOptions} from "../driver/ConnectionOptions";
|
||||
import {DriverOptions} from "../driver/DriverOptions";
|
||||
|
||||
/**
|
||||
* Options to be passed to find methods.
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import "reflect-metadata";
|
||||
import {expect} from "chai";
|
||||
import {createTestingConnectionOptions} from "../../utils/test-utils";
|
||||
import {CreateConnectionOptions} from "../../../src/connection/CreateConnectionOptions";
|
||||
import {ConnectionOptions} from "../../../src/connection/ConnectionOptions";
|
||||
import {ConnectionManager} from "../../../src/connection/ConnectionManager";
|
||||
import {MysqlDriver} from "../../../src/driver/MysqlDriver";
|
||||
import {PostgresDriver} from "../../../src/driver/PostgresDriver";
|
||||
@ -12,9 +12,9 @@ describe("ConnectionManager", () => {
|
||||
describe("create", function() {
|
||||
|
||||
it("should create a mysql connection when mysql driver is specified", () => {
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: createTestingConnectionOptions("mysql")
|
||||
driverOptions: createTestingConnectionOptions("mysql")
|
||||
};
|
||||
const connectionManager = new ConnectionManager();
|
||||
const connection = connectionManager.create(options);
|
||||
@ -22,10 +22,10 @@ describe("ConnectionManager", () => {
|
||||
});
|
||||
|
||||
it("should create a postgres connection when mysql driver is specified", () => {
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "postgres",
|
||||
connectionName: "myPostgresConnection",
|
||||
connection: createTestingConnectionOptions("postgres")
|
||||
driverOptions: createTestingConnectionOptions("postgres")
|
||||
};
|
||||
const connectionManager = new ConnectionManager();
|
||||
const connection = connectionManager.create(options);
|
||||
@ -57,10 +57,10 @@ describe("ConnectionManager", () => {
|
||||
describe("get", function() {
|
||||
|
||||
it("should give connection with a requested name", () => {
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connectionName: "myMysqlConnection",
|
||||
connection: createTestingConnectionOptions("mysql")
|
||||
driverOptions: createTestingConnectionOptions("mysql")
|
||||
};
|
||||
const connectionManager = new ConnectionManager();
|
||||
const connection = connectionManager.create(options);
|
||||
@ -69,10 +69,10 @@ describe("ConnectionManager", () => {
|
||||
});
|
||||
|
||||
it("should throw an error if connection with the given name was not found", () => {
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connectionName: "myMysqlConnection",
|
||||
connection: createTestingConnectionOptions("mysql")
|
||||
driverOptions: createTestingConnectionOptions("mysql")
|
||||
};
|
||||
const connectionManager = new ConnectionManager();
|
||||
const connection = connectionManager.create(options);
|
||||
|
||||
@ -17,7 +17,7 @@ import {TreeRepository} from "../../../src/repository/TreeRepository";
|
||||
import {ReactiveRepository} from "../../../src/repository/ReactiveRepository";
|
||||
import {TreeReactiveRepository} from "../../../src/repository/TreeReactiveRepository";
|
||||
import {getConnectionManager} from "../../../src/index";
|
||||
import {CreateConnectionOptions} from "../../../src/connection/CreateConnectionOptions";
|
||||
import {ConnectionOptions} from "../../../src/connection/ConnectionOptions";
|
||||
import {CannotSyncNotConnectedError} from "../../../src/connection/error/CannotSyncNotConnectedError";
|
||||
import {NoConnectionForRepositoryError} from "../../../src/connection/error/NoConnectionForRepositoryError";
|
||||
import {RepositoryNotFoundError} from "../../../src/connection/error/RepositoryNotFoundError";
|
||||
@ -40,9 +40,9 @@ describe("Connection", () => {
|
||||
|
||||
let connection: Connection;
|
||||
before(async () => {
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: createTestingConnectionOptions("mysql"),
|
||||
driverOptions: createTestingConnectionOptions("mysql"),
|
||||
entities: []
|
||||
};
|
||||
connection = await getConnectionManager().create(options);
|
||||
@ -227,11 +227,11 @@ describe("Connection", () => {
|
||||
beforeEach(async () => {
|
||||
firstConnection = await getConnectionManager().create({
|
||||
driver: "mysql",
|
||||
connection: createTestingConnectionOptions("mysql")
|
||||
driverOptions: createTestingConnectionOptions("mysql")
|
||||
});
|
||||
secondConnection = await getConnectionManager().create({
|
||||
driver: "mysql",
|
||||
connection: createTestingConnectionOptions("mysql")
|
||||
driverOptions: createTestingConnectionOptions("mysql")
|
||||
});
|
||||
});
|
||||
|
||||
@ -279,7 +279,7 @@ describe("Connection", () => {
|
||||
beforeEach(async () => {
|
||||
connection = await getConnectionManager().create({
|
||||
driver: "mysql",
|
||||
connection: createTestingConnectionOptions("mysql")
|
||||
driverOptions: createTestingConnectionOptions("mysql")
|
||||
});
|
||||
});
|
||||
afterEach(() => connection.isConnected ? connection.close() : {});
|
||||
@ -327,7 +327,7 @@ describe("Connection", () => {
|
||||
beforeEach(async () => {
|
||||
connection = await getConnectionManager().create({
|
||||
driver: "mysql",
|
||||
connection: createTestingConnectionOptions("mysql")
|
||||
driverOptions: createTestingConnectionOptions("mysql")
|
||||
});
|
||||
});
|
||||
afterEach(() => connection.isConnected ? connection.close() : {});
|
||||
|
||||
@ -4,7 +4,7 @@ import {Connection} from "../../../../src/connection/Connection";
|
||||
import {Repository} from "../../../../src/repository/Repository";
|
||||
import {Post} from "./entity/Post";
|
||||
import {Category} from "./entity/Category";
|
||||
import {CreateConnectionOptions} from "../../../../src/connection/CreateConnectionOptions";
|
||||
import {ConnectionOptions} from "../../../../src/connection/ConnectionOptions";
|
||||
import {createConnection} from "../../../../src/index";
|
||||
import {User} from "./entity/User";
|
||||
|
||||
@ -14,9 +14,9 @@ describe("persistence > many-to-many", function() {
|
||||
// Configuration
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
const parameters: CreateConnectionOptions = {
|
||||
const parameters: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -3,7 +3,7 @@ import {expect} from "chai";
|
||||
import {Connection} from "../../../../src/connection/Connection";
|
||||
import {Repository} from "../../../../src/repository/Repository";
|
||||
import {Post} from "./entity/Post";
|
||||
import {CreateConnectionOptions} from "../../../../src/connection/CreateConnectionOptions";
|
||||
import {ConnectionOptions} from "../../../../src/connection/ConnectionOptions";
|
||||
import {createConnection} from "../../../../src/index";
|
||||
import {SpecificRepository} from "../../../../src/repository/SpecificRepository";
|
||||
|
||||
@ -13,9 +13,9 @@ describe("repository > removeById and removeByIds methods", function() {
|
||||
// Configuration
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
const parameters: CreateConnectionOptions = {
|
||||
const parameters: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -4,7 +4,7 @@ import {Connection} from "../../../../src/connection/Connection";
|
||||
import {Repository} from "../../../../src/repository/Repository";
|
||||
import {Post} from "./entity/Post";
|
||||
import {Category} from "./entity/Category";
|
||||
import {CreateConnectionOptions} from "../../../../src/connection/CreateConnectionOptions";
|
||||
import {ConnectionOptions} from "../../../../src/connection/ConnectionOptions";
|
||||
import {createConnection} from "../../../../src/index";
|
||||
import {SpecificRepository} from "../../../../src/repository/SpecificRepository";
|
||||
|
||||
@ -14,9 +14,9 @@ describe("repository > set/add/remove relation methods", function() {
|
||||
// Configuration
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
const parameters: CreateConnectionOptions = {
|
||||
const parameters: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import "reflect-metadata";
|
||||
import {expect} from "chai";
|
||||
import {Connection} from "../../src/connection/Connection";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Repository} from "../../src/repository/Repository";
|
||||
import {PostDetails} from "../../sample/sample2-one-to-one/entity/PostDetails";
|
||||
import {Post} from "../../sample/sample2-one-to-one/entity/Post";
|
||||
@ -18,9 +18,9 @@ describe("one-to-one", function() {
|
||||
// Configuration
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "postgres",
|
||||
connection: createTestingConnectionOptions("postgres"),
|
||||
driverOptions: createTestingConnectionOptions("postgres"),
|
||||
entities: [Post, PostDetails, PostCategory, PostMetadata, PostImage, PostInformation, PostAuthor]
|
||||
};
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import "reflect-metadata";
|
||||
import {expect} from "chai";
|
||||
import {Connection} from "../../src/connection/Connection";
|
||||
import {createConnection, CreateConnectionOptions} from "../../src/index";
|
||||
import {createConnection, ConnectionOptions} from "../../src/index";
|
||||
import {Repository} from "../../src/repository/Repository";
|
||||
import {PostDetails} from "../../sample/sample3-many-to-one/entity/PostDetails";
|
||||
import {Post} from "../../sample/sample3-many-to-one/entity/Post";
|
||||
@ -18,9 +18,9 @@ describe("many-to-one", function() {
|
||||
// Configuration
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "postgres",
|
||||
connection: createTestingConnectionOptions("postgres"),
|
||||
driverOptions: createTestingConnectionOptions("postgres"),
|
||||
entities: [Post, PostDetails, PostCategory, PostMetadata, PostImage, PostInformation, PostAuthor]
|
||||
};
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import "reflect-metadata";
|
||||
import {expect} from "chai";
|
||||
import {Connection} from "../../src/connection/Connection";
|
||||
import {CreateConnectionOptions, createConnection} from "../../src/index";
|
||||
import {ConnectionOptions, createConnection} from "../../src/index";
|
||||
import {Repository} from "../../src/repository/Repository";
|
||||
import {PostDetails} from "../../sample/sample4-many-to-many/entity/PostDetails";
|
||||
import {Post} from "../../sample/sample4-many-to-many/entity/Post";
|
||||
@ -16,9 +16,9 @@ describe("many-to-many", function() {
|
||||
// Configuration
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
const options: CreateConnectionOptions = {
|
||||
const options: ConnectionOptions = {
|
||||
driver: "postgres",
|
||||
connection: createTestingConnectionOptions("postgres"),
|
||||
driverOptions: createTestingConnectionOptions("postgres"),
|
||||
entityDirectories: [__dirname + "/../../sample/sample4-many-to-many/entity/*"]
|
||||
};
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import {CreateConnectionOptions} from "../../src/connection/CreateConnectionOptions";
|
||||
import {ConnectionOptions} from "../../src/connection/ConnectionOptions";
|
||||
import {createConnection} from "../../src/index";
|
||||
import {Connection} from "../../src/connection/Connection";
|
||||
import {ConnectionOptions} from "../../src/driver/ConnectionOptions";
|
||||
import {DriverOptions} from "../../src/driver/DriverOptions";
|
||||
import {EntitySchema} from "../../src/metadata/entity-schema/EntitySchema";
|
||||
|
||||
export interface TestingConnectionOptions {
|
||||
@ -15,7 +15,7 @@ export function closeConnections(connections: Connection[]) {
|
||||
return Promise.all(connections.map(connection => connection.close()));
|
||||
}
|
||||
|
||||
export function createTestingConnectionOptions(type: "mysql"|"mysqlSecondary"|"postgres"|"postgresSecondary"): ConnectionOptions {
|
||||
export function createTestingConnectionOptions(type: "mysql"|"mysqlSecondary"|"postgres"|"postgresSecondary"): DriverOptions {
|
||||
const parameters = require(__dirname + "/../../../../config/parameters.json"); // path is relative to compile directory
|
||||
// const parameters = require(__dirname + "/../../config/parameters.json");
|
||||
|
||||
@ -35,38 +35,38 @@ export function createTestingConnectionOptions(type: "mysql"|"mysqlSecondary"|"p
|
||||
|
||||
export async function setupTestingConnections(options?: TestingConnectionOptions): Promise<Connection[]> {
|
||||
|
||||
const mysqlParameters: CreateConnectionOptions = {
|
||||
const mysqlParameters: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connectionName: "mysqlPrimaryConnection",
|
||||
connection: createTestingConnectionOptions("mysql"),
|
||||
driverOptions: createTestingConnectionOptions("mysql"),
|
||||
autoSchemaCreate: true,
|
||||
entities: options && options.entities ? options.entities : [],
|
||||
entitySchemas: options && options.entitySchemas ? options.entitySchemas : [],
|
||||
entityDirectories: options && options.entityDirectories ? options.entityDirectories : [],
|
||||
};
|
||||
|
||||
const mysqlSecondaryParameters: CreateConnectionOptions = {
|
||||
const mysqlSecondaryParameters: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connectionName: "mysqlSecondaryConnection",
|
||||
connection: createTestingConnectionOptions("mysqlSecondary"),
|
||||
driverOptions: createTestingConnectionOptions("mysqlSecondary"),
|
||||
entities: options && options.entities ? options.entities : [],
|
||||
entitySchemas: options && options.entitySchemas ? options.entitySchemas : [],
|
||||
entityDirectories: options && options.entityDirectories ? options.entityDirectories : [],
|
||||
};
|
||||
|
||||
const postgresParameters: CreateConnectionOptions = {
|
||||
const postgresParameters: ConnectionOptions = {
|
||||
driver: "postgres",
|
||||
connectionName: "postgresPrimaryConnection",
|
||||
connection: createTestingConnectionOptions("postgres"),
|
||||
driverOptions: createTestingConnectionOptions("postgres"),
|
||||
entities: options && options.entities ? options.entities : [],
|
||||
entitySchemas: options && options.entitySchemas ? options.entitySchemas : [],
|
||||
entityDirectories: options && options.entityDirectories ? options.entityDirectories : [],
|
||||
};
|
||||
|
||||
const postgresSecondaryParameters: CreateConnectionOptions = {
|
||||
const postgresSecondaryParameters: ConnectionOptions = {
|
||||
driver: "postgres",
|
||||
connectionName: "postgresSecondaryConnection",
|
||||
connection: createTestingConnectionOptions("postgresSecondary"),
|
||||
driverOptions: createTestingConnectionOptions("postgresSecondary"),
|
||||
entities: options && options.entities ? options.entities : [],
|
||||
entitySchemas: options && options.entitySchemas ? options.entitySchemas : [],
|
||||
entityDirectories: options && options.entityDirectories ? options.entityDirectories : [],
|
||||
@ -75,7 +75,7 @@ export async function setupTestingConnections(options?: TestingConnectionOptions
|
||||
const mysql = true;
|
||||
const postgres = false;
|
||||
|
||||
const allParameters: CreateConnectionOptions[] = [];
|
||||
const allParameters: ConnectionOptions[] = [];
|
||||
if (mysql)
|
||||
allParameters.push(mysqlParameters);
|
||||
if (postgres)
|
||||
@ -93,9 +93,9 @@ export async function setupTestingConnections(options?: TestingConnectionOptions
|
||||
*/
|
||||
export function setupConnection(callback: (connection: Connection) => any, entities: Function[]) {
|
||||
|
||||
const parameters: CreateConnectionOptions = {
|
||||
const parameters: ConnectionOptions = {
|
||||
driver: "mysql",
|
||||
connection: {
|
||||
driverOptions: {
|
||||
host: "192.168.99.100",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user