Skip to content
This repository has been archived by the owner on Mar 18, 2022. It is now read-only.

Commit

Permalink
feat: Aurora Data API (typeorm#4375)
Browse files Browse the repository at this point in the history
* Initial POC Implementation

* Initial POC Implementation

* Implemented an interface transformation between typeorm and data api so most of the queries should work, added some tests

* Fixed lint errors

* Fixed a regex and added some tests on query transformation

* Move out to a separate repo

* Bumped aurora driver version to latest

* Bumped aurora driver version to latest

* Delegate transactions to the driver

* Delegate transactions to the driver

* WIP

* WIP

* Bump the aurora driver version

* Bump the aurora driver version

* Fixed aurora driver version

* removed unused entity
  • Loading branch information
ArsenyYankovsky authored and pleerock committed Aug 13, 2019
1 parent b4e9cf0 commit c321562
Show file tree
Hide file tree
Showing 10 changed files with 2,555 additions and 1 deletion.
18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@
"sqlite3": "^4.0.9",
"ts-node": "^8.0.2",
"tslint": "^5.13.1",
"typescript": "^3.3.3333"
"typescript": "^3.3.3333",
"typeorm-aurora-data-api-driver": "^1.1.1"
},
"dependencies": {
"app-root-path": "^2.0.1",
Expand Down
3 changes: 3 additions & 0 deletions src/connection/ConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {SqljsConnectionOptions} from "../driver/sqljs/SqljsConnectionOptions";
import {ReactNativeConnectionOptions} from "../driver/react-native/ReactNativeConnectionOptions";
import {NativescriptConnectionOptions} from "../driver/nativescript/NativescriptConnectionOptions";
import {ExpoConnectionOptions} from "../driver/expo/ExpoConnectionOptions";
import {AuroraDataApiConnectionOptions} from "../driver/aurora-data-api/AuroraDataApiConnectionOptions";


/**
* ConnectionOptions is an interface with settings and options for specific connection.
Expand All @@ -28,4 +30,5 @@ export type ConnectionOptions =
ReactNativeConnectionOptions|
SqljsConnectionOptions|
MongoConnectionOptions|
AuroraDataApiConnectionOptions|
ExpoConnectionOptions;
3 changes: 3 additions & 0 deletions src/driver/DriverFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {SqljsDriver} from "./sqljs/SqljsDriver";
import {MysqlDriver} from "./mysql/MysqlDriver";
import {PostgresDriver} from "./postgres/PostgresDriver";
import {ExpoDriver} from "./expo/ExpoDriver";
import {AuroraDataApiDriver} from "./aurora-data-api/AuroraDataApiDriver";
import {Driver} from "./Driver";
import {Connection} from "../connection/Connection";

Expand Down Expand Up @@ -51,6 +52,8 @@ export class DriverFactory {
return new MongoDriver(connection);
case "expo":
return new ExpoDriver(connection);
case "aurora-data-api":
return new AuroraDataApiDriver(connection);
default:
throw new MissingDriverError(type);
}
Expand Down
20 changes: 20 additions & 0 deletions src/driver/aurora-data-api/AuroraDataApiConnection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {AuroraDataApiQueryRunner} from "./AuroraDataApiQueryRunner";
import {Connection} from "../../connection/Connection";
import {ConnectionOptions, QueryRunner} from "../..";

/**
* Organizes communication with MySQL DBMS.
*/
export class AuroraDataApiConnection extends Connection {
queryRunnter: AuroraDataApiQueryRunner;

constructor(options: ConnectionOptions, queryRunner: AuroraDataApiQueryRunner) {
super(options);
this.queryRunnter = queryRunner;
}

public createQueryRunner(mode: "master" | "slave" = "master"): QueryRunner {
return this.queryRunnter;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* MySQL specific connection credential options.
*
* @see https://github.com/mysqljs/mysql#connection-options
*/
export interface AuroraDataApiConnectionCredentialsOptions {

/**
* Connection url where perform connection to.
*/
readonly url?: string;

/**
* Database host.
*/
readonly host?: string;

/**
* Database host port.
*/
readonly port?: number;

/**
* Database username.
*/
readonly username?: string;

/**
* Database password.
*/
readonly password?: string;

/**
* Database name to connect to.
*/
readonly database?: string;

/**
* Object with ssl parameters or a string containing name of ssl profile.
*/
readonly ssl?: any;

}
23 changes: 23 additions & 0 deletions src/driver/aurora-data-api/AuroraDataApiConnectionOptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {BaseConnectionOptions} from "../../connection/BaseConnectionOptions";
import {AuroraDataApiConnectionCredentialsOptions} from "./AuroraDataApiConnectionCredentialsOptions";

/**
* MySQL specific connection options.
*
* @see https://github.com/mysqljs/mysql#connection-options
*/
export interface AuroraDataApiConnectionOptions extends BaseConnectionOptions, AuroraDataApiConnectionCredentialsOptions {

/**
* Database type.
*/
readonly type: "aurora-data-api";

readonly region: string;

readonly secretArn: string;

readonly resourceArn: string;

readonly database: string;
}
Loading

0 comments on commit c321562

Please sign in to comment.