feat(medusa): Expose an activeManager_ getter in TransactionBaseService (#3256)
This commit is contained in:
@@ -1,13 +1,9 @@
|
||||
import { EntityManager } from "typeorm"
|
||||
import { MockManager } from "medusa-test-utils"
|
||||
import { TransactionBaseService } from "../transaction-base-service"
|
||||
|
||||
describe("TransactionBaseService", () => {
|
||||
it("should cloned the child class withTransaction", () => {
|
||||
class Child extends TransactionBaseService {
|
||||
protected manager_!: EntityManager
|
||||
protected transactionManager_!: EntityManager
|
||||
|
||||
constructor(protected readonly container) {
|
||||
super(container);
|
||||
this.container = container
|
||||
|
||||
@@ -2,14 +2,20 @@ import { EntityManager } from "typeorm"
|
||||
import { IsolationLevel } from "typeorm/driver/types/IsolationLevel"
|
||||
|
||||
export abstract class TransactionBaseService {
|
||||
protected abstract manager_: EntityManager
|
||||
protected abstract transactionManager_: EntityManager | undefined
|
||||
protected manager_: EntityManager
|
||||
protected transactionManager_: EntityManager | undefined
|
||||
|
||||
protected get activeManager_(): EntityManager {
|
||||
return this.transactionManager_ ?? this.manager_
|
||||
}
|
||||
|
||||
protected constructor(
|
||||
protected readonly __container__: any,
|
||||
protected readonly __configModule__?: Record<string, unknown>,
|
||||
protected readonly __moduleDeclaration__?: Record<string, unknown>
|
||||
) {}
|
||||
) {
|
||||
this.manager_ = __container__.manager
|
||||
}
|
||||
|
||||
withTransaction(transactionManager?: EntityManager): this {
|
||||
if (!transactionManager) {
|
||||
|
||||
Reference in New Issue
Block a user