Created
March 22, 2019 03:22
-
-
Save Diluka/87efbd9169cae96a012a43d1e5695667 to your computer and use it in GitHub Desktop.
Patch CLS support to typeorm using typeorm-transactional-cls-hooked
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Repository } from 'typeorm'; | |
import { BaseRepository, initializeTransactionalContext } from 'typeorm-transactional-cls-hooked'; | |
initializeTransactionalContext(); | |
for (const p of Object.getOwnPropertyNames(BaseRepository.prototype)) { | |
Object.defineProperty(Repository.prototype, p, Object.getOwnPropertyDescriptor(BaseRepository.prototype, p)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment