typeorm-transactional-cls-hooked icon indicating copy to clipboard operation
typeorm-transactional-cls-hooked copied to clipboard

EntityManager is Undefined

Open sgentile opened this issue 3 years ago • 0 comments

I setup per the documentation, but when this is called entitymanager is undefined:

save<T extends DeepPartial<Entity>>(entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {
        return this.manager.save<T>(this.metadata.target as any, entityOrEntities as any, options);
    }

my index:

initializeTransactionalContext();
serve();

my respository:

@EntityRepository(User)
export class UserRepository extends BaseRepository<User> {}

my service injecting it

export class UserService {
    constructor(
        private readonly userRepository: UserRepository
    ) {}

lastly the call to save

return await this.userRepository.save(user);

sgentile avatar Feb 25 '21 16:02 sgentile