Skip to content

Commit

Permalink
Bumps TypeORM to 0.1.1
Browse files Browse the repository at this point in the history
This also introduces `readonly` access modifier on `entityManager`
property of `TypeORMProvider` and gives a clear-er way of deprecating
the property altogether in the future.

Closes #17
  • Loading branch information
mishok13 committed Oct 18, 2017
1 parent 70668e8 commit ed53a0c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,10 @@ adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## Unreleased

### Changed
* `providers.TypeORMProvider`'s `entityManager` is now `readonly`
* TypeORM dependency has been updated to `0.1.1` release

## [0.5.1] - 2017-10-06

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -78,7 +78,7 @@
"mysql": "^2.14.1",
"reflect-metadata": "^0.1.10",
"rxjs": "^5.4.3",
"typeorm": "0.0.11",
"typeorm": "^0.1.1",
"uuid": "^3.1.0"
}
}
10 changes: 5 additions & 5 deletions src/providers/typeorm.ts
Expand Up @@ -8,7 +8,7 @@ import { Config, HealthManager, Logger } from '../';
@injectable()
export class TypeORMProvider {
public connection: Connection;
public entityManager: EntityManager;
public readonly entityManager: EntityManager;
public health = new BehaviorSubject(false);

public defaultConnectionOptions = {
Expand Down Expand Up @@ -36,8 +36,8 @@ export class TypeORMProvider {
options.driver.username = this.config['dbUser'];
options.driver.password = this.config['dbPassword'] || '';
options.driver.database = this.config['dbName'];
options.driver.host = this.config['dbHost'];
options.driver.port = this.config['dbPort'];
options.driver.host = this.config['dbHost'];
options.driver.port = this.config['dbPort'];

// We dont support autoschema sync, because we want to have auto retrying connection
// we need to use connectionManager.create which doesn't support auto schema sync
Expand All @@ -47,7 +47,7 @@ export class TypeORMProvider {

const connectionManager = getConnectionManager();
this.connection = connectionManager.create(options);
this.entityManager = this.connection.entityManager;
this.entityManager = this.connection.manager;
this.connect();
}

Expand All @@ -69,7 +69,7 @@ export class TypeORMProvider {
// Monitors database connection and will update the health accordingly
private monitorHealth() {
setInterval(() => {
this.entityManager.query('SELECT 1;')
this.connection.manager.query('SELECT 1;')
.then(() => {
this.health.next(true);
})
Expand Down

0 comments on commit ed53a0c

Please sign in to comment.