title: How to save Column with @Afterload , Nested Relations TypeORM
body: <p>I want to put the number of posts in my user profile entity.</p>
  <ul>
  <li>user_profile.entity.ts</li>
  </ul>
  <pre class="lang-js prettyprint-override"><code>@Entity()
  @Unique(['username'])
  export class UserProfile {
    /** Columns */
    @PrimaryGeneratedColumn('uuid')
    readonly id: string;
   
    @Column('timestamptz')
    @CreateDateColumn()
    readonly created_at: Date;
   
    @Column('timestamptz')
    @UpdateDateColumn()
    readonly updated_at: Date;
   
    @ApiProperty()
    @Column({ length: 255 })
    @IsString()
    @Length(3, 50)
    username: string;
   
    @Column()
    post_count: number;
   
    @ApiProperty({ readOnly: true })
    @Column('uuid')
    @IsUUID('4')
    user_id: string;
   
    @ApiProperty({ readOnly: true })
    @Column({ default: 0, nullable: true })
    @IsOptional()
    exp?: number;
   
    @ApiProperty({ readOnly: true })
    @Column({ default: 1, nullable: true })
    @IsOptional()
    level?: number;
   
    /** Relations */
    @OneToOne((type) =&gt; User, (user) =&gt; user.profile, { onDelete: 'CASCADE' })
    @JoinColumn({ name: 'user_id', referencedColumnName: 'id' })
    user: User;
   
    // ** Hooks
   
    @AfterLoad()
    updatePostCount() {
  this.post_count = this.user.posts.length;
    }
  }
  
  </code></pre>
  <ul>
  <li>user.entity.ts</li>
  </ul>
  <pre class="lang-js prettyprint-override"><code>@Entity()
  @Unique(['email'])
  @Check(`
    COALESCE((provider = 'local')::integer, 0) 
    + 
    COALESCE(LENGTH(social_id::text)::boolean::integer, 0)
    = 1
  `)
  export class User {
    /** Columns */
   
    @ApiProperty()
    @PrimaryGeneratedColumn('uuid')
    readonly id: string;
   
    @ApiProperty()
    @Column('timestamptz')
    @CreateDateColumn()
    readonly created_at: Date;
   
    @ApiProperty()
    @Column('timestamptz')
    @UpdateDateColumn()
    readonly updated_at: Date;
   
    @ApiProperty()
    @Column({ length: 255 })
    @IsEmail()
    email: string;
   
    /** Relations */
   
    @OneToMany((type) =&gt; Post, (post) =&gt; post.author)
    posts: Post[];
   
    @ApiProperty()
    @OneToOne((type) =&gt; UserProfile, (userProfile) =&gt; userProfile.user, {
      cascade: true,
    })
    profile: UserProfile;
   
    @AfterLoad()
    asdfasdf() {
      console.log('유저 entity :');
    }
  }
  
  </code></pre>
  <ul>
  <li>post.entity.ts</li>
  </ul>
  <pre class="lang-js prettyprint-override"><code>@Entity()
  export class Post {
    /** Columns */
   
    @PrimaryGeneratedColumn('uuid')
    readonly id: string;
   
    @Column('timestamptz')
    @CreateDateColumn()
    readonly created_at: Date;
   
    @Column('timestamptz')
    @UpdateDateColumn()
    readonly updated_at: Date;
   
    @ApiProperty()
    @Column({ length: 255 })
    @IsString()
    title: string;
   
    @ApiProperty()
    @Column('text')
    @IsString()
    contents: string;
   
    @ApiProperty({ readOnly: true })
    @Column('uuid')
    @IsUUID('4')
    user_id: string;
   
    /** Relations */
    @ManyToOne((type) =&gt; User, (user) =&gt; user.posts, {
      cascade: true,
      // eager: true,
      onDelete: 'CASCADE',
    })
    @JoinColumn({ name: 'user_id', referencedColumnName: 'id' })
    author: User;
  }
  
  </code></pre>
  <ul>
  <li>users.service.ts</li>
  </ul>
  <pre class="lang-js prettyprint-override"><code>
    async getMyUser(user_id: string) {
      const test = await this.userProfileRepository
        .createQueryBuilder('user_profile')
        .leftJoinAndSelect('user_profile.user', 'user')
        .leftJoinAndSelect('user.posts', 'posts')
        .where('user.id = :id', { id: user_id })
        .getOne();
  
      return test;
    }
  
    async getUserProfile(user_id: string): Promise&lt;UserProfileResponseDto&gt; {
      try {
        const user = await this.userRepository
          .createQueryBuilder('user')
          .leftJoinAndSelect('user.profile', 'user_profile')
          .leftJoinAndSelect('user.followers', 'followers')
          .leftJoinAndSelect('user.following', 'following')
          .leftJoinAndSelect('user.posts', 'posts')
          .where('user.id = :id', { id: user_id })
          .getOne();
  
        if (!user) {
          throw new Error();
        }
        return {
          profile: user.profile,
          followers: user.followers.length,
          following: user.following.length,
          posts: user.posts.length,
        };
      } catch (err) {
        throw new BadRequestException('Invalid user_id');
      }
    }
  </code></pre>
  <p>In <code>user_profile</code> entity, I used <code>@Afterload</code>,</p>
  <p>When I use <code>userPrifileRepository</code>(getMyUser), the output is good,
  but if I use <code>userRepository</code>(getUserProfile), it doesn't come out. (<code>this.user</code> or <code>this.user.posts.length</code> was printed as undefined.)</p>
  <p>And even if the output was good, it could not be saved.
  <code>this.post_count = this.user.posts.length</code></p>