title: how to create relationship between two entities with foreign key using typeorm
body: <p>I need to create a relationship between two entities, I need that whenever I create a new user, a user account is created where the owner is the id of the created user.</p>
  <p><strong>Rules:</strong></p>
  <ol>
  <li>When registering a new user must belong to a user account.</li>
  <li>Each user account must have an owner.</li>
  <li>I can have multiple users linked to one user account.</li>
  </ol>
  <p><strong>Below is the code I have today.</strong></p>
  <pre><code>@Entity()
  export class User extends BaseEntity { 
      @PrimaryGeneratedColumn('uuid')
      public id!: string;
      
      //cannot be null
      @ManyToOne(() =&gt; UserAccount, (obj) =&gt; obj.user)
      public userAccount: Relation&lt;UserAccount&gt;; 
  }
  
  
  @Entity()
  export class UserAccount extends BaseEntity {
    @PrimaryGeneratedColumn('uuid')
    public id!: string;
    
    // must be unique and cannot be null
    @OneToOne(() =&gt; User, (user) =&gt; user.id)
    public owner: Relation&lt;User&gt;;
  
    @OneToMany(() =&gt; User, (obj) =&gt; obj.userAccount)
    public user: Relation&lt;User&gt;;
  }
  </code></pre>
  <p>I tried the way it is above but it doesn't meet the rules described above.</p>
  <p><strong>How do I create the relationship between these two entities in a way that respects the rules described above?</strong></p>