Skip to content

Commit 04753c5

Browse files
Update content/techniques/mongo.md
1 parent e6c340c commit 04753c5

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

content/techniques/mongo.md

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -222,22 +222,16 @@ export class CatsService {
222222
}
223223
```
224224

225-
It's also possible to inject any `Connection` to the providers:
225+
To inject a given `Connection` to a custom provider (for example, factory provider), use the `getConnectionToken()` function passing the name of the connection as an argument.
226226

227227
```typescript
228-
@Module({
229-
providers: [
230-
{
231-
provide: CatsService,
232-
useFactory: (catsConnection: Connection) => {
233-
return new CatsService(catsConnection);
234-
},
235-
inject: [getConnectionToken('cats')],
236-
},
237-
],
238-
})
239-
export class CatsModule {}
240-
```
228+
{
229+
provide: CatsService,
230+
useFactory: (catsConnection: Connection) => {
231+
return new CatsService(catsConnection);
232+
},
233+
inject: [getConnectionToken('cats')],
234+
}
241235

242236
#### Hooks (middleware)
243237

0 commit comments

Comments
 (0)