Skip to content

Changes to use typeorm version 0.3.x #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ export class PostRepository {
}
```

You can also Inject an entity by forcing it to take on a specific type:
Repository, MongoRepository or TreeRepository
```ts
class SampleClass {
\@InjectRepository(User, "Repository")
userRepository: Repository<User>;
constructor(@InjectRepository(User, "Repository") private userRepository: Repository<User>) {}
}
```


You can also inject custom `Repository` of some Entity. To make this work have to create the class which extends the
generic `Repository<T>` class and decorate it with `EntityRepository<T>` decorator.

Expand Down Expand Up @@ -156,4 +167,20 @@ export class PostService {
}
```


To use the plugin with Typeorm version 0.3.x:

To use in new versions of typeorm, it will be necessary to use the useConnection.setDatasource method, it expects a datasource as a parameter

example:

```typescript
import { useConnection } from 'typeorm-typedi-extensions';


const connection = new Datasource({...paramsToConnection})
useConnection.setDatasource(connection)
``````


[typedi]: https://github.com/typestack/typedi
Loading