Skip to content
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

fix(typeorm-common): update repository to get entityManager from opti… #151

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(typeorm-common): update repository to get entityManager from opti…
…ons when needed
concepta-thiago committed Apr 22, 2024
commit dff7613b316e1abfc8dcb92e52e46d5662d146b3
11 changes: 7 additions & 4 deletions packages/typeorm-common/src/proxies/entity-manager.proxy.ts
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@ import { TransactionProxy } from './transaction.proxy';
export class EntityManagerProxy {
constructor(private _entityManager: EntityManager) {}

entityManager(options?: EntityManagerOptionInterface) {
return options?.entityManager ?? this._entityManager;
entityManager() {
return this._entityManager;
}

repository<T extends ObjectLiteral>(
@@ -17,8 +17,11 @@ export class EntityManagerProxy {
): Repository<T> {
if (options?.transaction) {
return options.transaction.repository(repository);
} else if (this.entityManager(options) !== this._entityManager) {
return this._entityManager.withRepository<T, Repository<T>>(repository);
} else if (
options?.entityManager &&
options?.entityManager !== repository.manager
) {
return options.entityManager.withRepository<T, Repository<T>>(repository);
} else {
return repository;
}