title: TypeORM bidirectional composite primary key relations
body: <p>One <code>User</code> can have multiple <code>Profiles</code>. In the <code>User</code> I only want to store the <code>profileId</code>. In the <code>Profile</code> I want to store the id of the <code>User</code>.</p>
  
  <h2>User</h2>
  
  <pre><code>@Entity()
  export class User {
    @PrimaryGeneratedColumn()
    id: string;
  
    @Column({ nullable: true })
    public profileId?: string;
  
    @OneToOne(
      type =&gt; Profile,
      profile =&gt; profile.user
    )
    @JoinColumn()
    profile: Profile;
  }
  </code></pre>
  
  <h2>Profile</h2>
  
  <pre><code>@Entity()
  export class Profile {
    @PrimaryGeneratedColumn()
    id: string;
  
    @PrimaryColumn()
    userId: string;
  
    @OneToOne(
      type =&gt; User,
      user =&gt; user.profile
    )
    user: User;
  }
  </code></pre>
  
  <p>In simple words I want to create two foreign keys. From <code>User.profileId</code> to the <code>Profile.id</code> and from <code>Profile.userId</code> to the <code>User.Id</code>. Is this the best practise solution for my problem?</p>