@@ -33,7 +33,7 @@ createConnection({
33
33
All decorators can be used on properties and constructor arguments, e.g. you can use both
34
34
property and constructor injection.
35
35
36
- ### @OrmConnection
36
+ ### @InjectConnection
37
37
38
38
Injects ` Connection ` from where you can access anything in your connection.
39
39
@@ -42,12 +42,12 @@ Example using property injection:
42
42
``` typescript
43
43
import {Service } from " typedi" ;
44
44
import {Connection } from " typeorm" ;
45
- import {OrmConnection } from " typeorm-typedi-extensions" ;
45
+ import {InjectConnection } from " typeorm-typedi-extensions" ;
46
46
47
47
@Service ()
48
48
export class PostRepository {
49
49
50
- @OrmConnection ()
50
+ @InjectConnection ()
51
51
private connection: Connection ;
52
52
53
53
}
@@ -58,20 +58,20 @@ Example using constructor injection:
58
58
``` typescript
59
59
import {Service } from " typedi" ;
60
60
import {Connection } from " typeorm" ;
61
- import {OrmConnection } from " typeorm-typedi-extensions" ;
61
+ import {InjectConnection } from " typeorm-typedi-extensions" ;
62
62
63
63
@Service ()
64
64
export class PostRepository {
65
65
66
- constructor (@OrmConnection () private connection : Connection ) {
66
+ constructor (@InjectConnection () private connection : Connection ) {
67
67
}
68
68
69
69
}
70
70
```
71
71
72
72
Optionally, you can specify a connection name in the decorator parameters.
73
73
74
- ### @OrmManager
74
+ ### @InjectManager
75
75
76
76
Injects ` EntityManager ` from where you can access any entity in your connection.
77
77
@@ -80,12 +80,12 @@ Example using property injection:
80
80
``` typescript
81
81
import {Service } from " typedi" ;
82
82
import {EntityManager } from " typeorm" ;
83
- import {OrmManager } from " typeorm-typedi-extensions" ;
83
+ import {InjectManager } from " typeorm-typedi-extensions" ;
84
84
85
85
@Service ()
86
86
export class PostRepository {
87
87
88
- @OrmManager ()
88
+ @InjectManager ()
89
89
private entityManager: EntityManager ;
90
90
91
91
}
@@ -96,36 +96,36 @@ Example using constructor injection:
96
96
``` typescript
97
97
import {Service } from " typedi" ;
98
98
import {EntityManager } from " typeorm" ;
99
- import {OrmManager } from " typeorm-typedi-extensions" ;
99
+ import {InjectManager } from " typeorm-typedi-extensions" ;
100
100
101
101
@Service ()
102
102
export class PostRepository {
103
103
104
- constructor (@OrmManager () private entityManager : EntityManager ) {
104
+ constructor (@InjectManager () private entityManager : EntityManager ) {
105
105
}
106
106
107
107
}
108
108
```
109
109
110
110
Optionally, you can specify a connection name in the decorator parameters.
111
111
112
- ### @OrmRepository
112
+ ### @InjectRepository
113
113
114
114
Injects ` Repository ` , ` MongoRepository ` , ` TreeRepository ` or custom repository of some Entity.
115
- Be aware that the property or param decorated with ` @OrmRepository ` has to be annotated with repository type!
115
+ Be aware that the property or param decorated with ` @InjectRepository ` has to be annotated with repository type!
116
116
117
117
Example using property injection:
118
118
119
119
``` typescript
120
120
import {Service } from " typedi" ;
121
121
import {Repository } from " typeorm" ;
122
- import {OrmRepository } from " typeorm-typedi-extensions" ;
122
+ import {InjectRepository } from " typeorm-typedi-extensions" ;
123
123
import " ../entity/Post" ;
124
124
125
125
@Service ()
126
126
export class PostRepository {
127
127
128
- @OrmRepository (Post )
128
+ @InjectRepository (Post )
129
129
private repository: Repository <Post >;
130
130
131
131
}
@@ -136,14 +136,14 @@ Example using constructor injection:
136
136
``` typescript
137
137
import {Service } from " typedi" ;
138
138
import {Repository } from " typeorm" ;
139
- import {OrmRepository } from " typeorm-typedi-extensions" ;
139
+ import {InjectRepository } from " typeorm-typedi-extensions" ;
140
140
import " ../entity/Post" ;
141
141
142
142
@Service ()
143
143
export class PostRepository {
144
144
145
145
constructor (
146
- @OrmRepository (Post )
146
+ @InjectRepository (Post )
147
147
private repository : Repository <Post >
148
148
) {}
149
149
@@ -155,7 +155,7 @@ Optionally, you can specify a connection name in the decorator parameters:
155
155
@Service ()
156
156
export class PostRepository {
157
157
158
- @OrmRepository (Post , " custom-con-name" )
158
+ @InjectRepository (Post , " custom-con-name" )
159
159
private repository: Repository <Post >;
160
160
161
161
}
@@ -169,7 +169,7 @@ Example using constructor injection:
169
169
``` typescript
170
170
import { Service } from " typedi" ;
171
171
import { Repository , EntityRepository } from " typeorm" ;
172
- import { OrmRepository } from " typeorm-typedi-extensions" ;
172
+ import { InjectRepository } from " typeorm-typedi-extensions" ;
173
173
import " ../entity/user" ;
174
174
175
175
// create custom Repository class
@@ -188,7 +188,7 @@ export class PostService {
188
188
189
189
// using constructor injection
190
190
constructor (
191
- @OrmRepository ()
191
+ @InjectRepository ()
192
192
private readonly userRepository : UserRepository ,
193
193
) {}
194
194
@@ -205,7 +205,7 @@ Optionally, you can specify a connection name in the decorator parameters.
205
205
@Service ()
206
206
export class PostService {
207
207
208
- @OrmRepository (" custom-con-name" )
208
+ @InjectRepository (" custom-con-name" )
209
209
private userRepository: UserRepository ;
210
210
211
211
}
0 commit comments