Skip to content

Instantly share code, notes, and snippets.

@Diluka
Created March 22, 2019 03:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Diluka/87efbd9169cae96a012a43d1e5695667 to your computer and use it in GitHub Desktop.
Save Diluka/87efbd9169cae96a012a43d1e5695667 to your computer and use it in GitHub Desktop.
Patch CLS support to typeorm using typeorm-transactional-cls-hooked
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