title: In nest js foreign key constraint are not working properly
body: <p>I am new this framework. I tried to add one to one relationship and post the data using postman. Data also successfully inserted. SO, I will check the database foreign key field are showing null values. I tried many ways but I couldn't get the answer. How to fix it.</p>
  <p><strong>user.entity.ts</strong></p>
  <pre><code>import { CustomerEntity } from &quot;src/customers/customer.entity&quot;;
  import {Entity, PrimaryGeneratedColumn, Column, OneToOne, JoinColumn} from &quot;typeorm&quot;;
  
  
  @Entity()
  export class UserEntity {
  
      @PrimaryGeneratedColumn()
      id: number
  
      @Column({ type: &quot;integer&quot; })
      userId: number;
          
      @OneToOne(type =&gt; CustomerEntity, car =&gt; car.user)
      @JoinColumn()
      car: CustomerEntity
  
  }
  </code></pre>
  <p><strong>customer.entity.ts</strong></p>
  <pre><code>import { UserEntity } from &quot;src/users/user.entity&quot;;
  import {Entity, PrimaryGeneratedColumn, Column, OneToOne, PrimaryColumn} from &quot;typeorm&quot;;
  
  @Entity()
  export class CustomerEntity {
  
      @PrimaryColumn()
      id: number
  
      @Column({ type: &quot;integer&quot; })
      sample: number;
  
      @OneToOne(type =&gt; UserEntity, user =&gt; user.car)
      user: UserEntity | null
  
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/PaEKk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PaEKk.png" alt="enter image description here" /></a></p>
  <p>How to implement one to one relationship in Nest JS I need Working Example code</p>