Skip to content

Commit 601442c

Browse files
author
Umed Khudoiberdiev
committed
updated all dependencies, renamed OrmEntityManager to OrmManager decorator
1 parent 11d41c8 commit 601442c

File tree

6 files changed

+36
-36
lines changed

6 files changed

+36
-36
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class PostRepository {
7171

7272
Optionally, you can specify a connection name in the decorator parameters.
7373

74-
### @OrmEntityManager
74+
### @OrmManager
7575

7676
Injects `EntityManager` from where you can access any entity in your connection.
7777

@@ -80,12 +80,12 @@ Example using property injection:
8080
```typescript
8181
import {Service} from "typedi";
8282
import {EntityManager} from "typeorm";
83-
import {OrmEntityManager} from "typeorm-typedi-extensions";
83+
import {OrmManager} from "typeorm-typedi-extensions";
8484

8585
@Service()
8686
export class PostRepository {
8787

88-
@OrmEntityManager()
88+
@OrmManager()
8989
private entityManager: EntityManager;
9090

9191
}
@@ -96,12 +96,12 @@ Example using constructor injection:
9696
```typescript
9797
import {Service} from "typedi";
9898
import {EntityManager} from "typeorm";
99-
import {OrmEntityManager} from "typeorm-typedi-extensions";
99+
import {OrmManager} from "typeorm-typedi-extensions";
100100

101101
@Service()
102102
export class PostRepository {
103103

104-
constructor(@OrmEntityManager() private entityManager: EntityManager) {
104+
constructor(@OrmManager() private entityManager: EntityManager) {
105105
}
106106

107107
}

package.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "typeorm-typedi-extensions",
3-
"version": "0.1.0",
3+
"version": "0.0.12",
44
"description": "Dependancy injection and service container integration with TypeORM using typedi library.",
55
"license": "MIT",
66
"readmeFilename": "README.md",
@@ -29,27 +29,27 @@
2929
"typeorm-typedi"
3030
],
3131
"devDependencies": {
32-
"@types/node": "^7.0.4",
33-
"chai": "^3.5.0",
34-
"del": "^2.2.2",
32+
"@types/node": "^8.0.31",
33+
"chai": "^4.1.2",
34+
"del": "^3.0.0",
3535
"gulp": "^3.9.1",
36-
"gulp-mocha": "^3.0.1",
37-
"gulp-replace": "^0.5.4",
38-
"gulp-shell": "^0.5.2",
39-
"gulp-tslint": "^6.1.2",
40-
"gulpclass": "^0.1.1",
41-
"pg": "^6.1.0",
42-
"reflect-metadata": "^0.1.9",
43-
"sinon-chai": "^2.9.0",
44-
"ts-node": "^1.3.0",
45-
"tslint": "^3.15.1",
46-
"tslint-stylish": "^2.1.0-beta",
36+
"gulp-mocha": "^4.3.1",
37+
"gulp-replace": "^0.6.1",
38+
"gulp-shell": "^0.6.3",
39+
"gulp-tslint": "^8.1.2",
40+
"gulpclass": "^0.1.2",
41+
"mysql": "^2.14.1",
42+
"reflect-metadata": "^0.1.10",
43+
"sinon-chai": "^2.13.0",
44+
"ts-node": "^3.3.0",
45+
"tslint": "^5.7.0",
46+
"tslint-stylish": "^2.1.0",
4747
"typedi": "^0.5.2",
48-
"typeorm": "^0.1.0-alpha.47",
49-
"typescript": "^2.5.2"
48+
"typeorm": "0.1.0-alpha.49",
49+
"typescript": "^2.5.3"
5050
},
5151
"peerDependencies": {
52-
"typeorm": "^0.1.0-alpha.47",
53-
"typedi": "^0.5.2"
52+
"typedi": "^0.5.2",
53+
"typeorm": "0.1.0-alpha.49"
5454
}
5555
}

sample/sample1-simple-usage/app.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ import {Post} from "./entity/Post";
66

77
useContainer(Container);
88
createConnection({
9-
type: "postgres",
9+
type: "mysql",
1010
host: "localhost",
11-
port: 5432,
11+
port: 3306,
1212
username: "test",
13-
password: "admin",
13+
password: "test",
1414
database: "test",
1515
entities: [
1616
__dirname + "/entity/*.js"
1717
],
18-
autoSchemaSync: true
18+
synchronize: true
1919
}).then(async connection => {
2020
console.log("connected");
2121

sample/sample1-simple-usage/repository/PostRepository.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import {Repository, EntityManager} from "typeorm";
1+
import {EntityManager, Repository} from "typeorm";
22
import {Service} from "typedi";
33
import {Post} from "../entity/Post";
44
import {OrmRepository} from "../../../src/decorators/OrmRepository";
5-
import {OrmEntityManager} from "../../../src/decorators/OrmEntityManager";
5+
import {OrmManager} from "../../../src/decorators/OrmManager";
66

77
@Service()
88
export class PostRepository {
99

10-
@OrmEntityManager()
10+
@OrmManager()
1111
private entityManager: EntityManager;
1212

1313
constructor(@OrmRepository(Post) private ormRepository: Repository<Post>) {
1414
}
1515

1616
saveUsingRepository(post: Post) {
17-
return this.ormRepository.persist(post);
17+
return this.ormRepository.save(post);
1818
}
1919

2020
saveUsingManager(post: Post) {
21-
return this.entityManager.persist(post);
21+
return this.entityManager.save(post);
2222
}
2323

2424
findAll() {

src/decorators/OrmEntityManager.ts renamed to src/decorators/OrmManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {Container} from "typedi";
44
/**
55
* Allows to inject an EntityManager using typedi's Container.
66
*/
7-
export function OrmEntityManager(connectionName: string = "default"): Function {
7+
export function OrmManager(connectionName: string = "default"): Function {
88
return function(object: Object|Function, propertyName: string, index?: number) {
99
Container.registerHandler({ object, index, propertyName, value: () => {
1010
const connectionManager = Container.get(ConnectionManager);
@@ -14,7 +14,7 @@ export function OrmEntityManager(connectionName: string = "default"): Function {
1414
`in your application before you established a connection and importing any entity.`);
1515

1616
const connection = connectionManager.get(connectionName);
17-
const entityManager = connection.entityManager;
17+
const entityManager = connection.manager;
1818
if (!entityManager)
1919
throw new Error(`Entity manager was not found on "${connectionName}" connection. ` +
2020
`Make sure you correctly setup connection and container usage.`);

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export * from "./decorators/OrmConnection";
2-
export * from "./decorators/OrmEntityManager";
2+
export * from "./decorators/OrmManager";
33
export * from "./decorators/OrmRepository";

0 commit comments

Comments
 (0)