title: One to one relation in typeorm mongo db
body: <p>How I achieve a one-to-one relationship using Typeform MongoDB.</p>
  
  <p>I m trying to join two documents using aggregation but not achieve success.</p>
  
  <p>Please provide one solution.</p>
  
  <p>Entity details
  1.counrty :- _id,name
  2.state :- _id,name, countryid</p>
  
  <pre><code>export class Country {
      @ObjectIdColumn()
      @Type(() =&gt; String)
      _id: ObjectID;
  
  
      @Column()
      @IsString()
      @IsNotEmpty()
      @Index({unique: true})
      name: string;
  
  }
  </code></pre>
  
  <pre><code>@Entity()
  export class State {
      @ObjectIdColumn()
      @Type(() =&gt; String)
      _id: ObjectID;
  
      @Column()
      @IsNotEmpty()
      name: string;
  
      @ObjectIdColumn({nullable: false})
      @IsNotEmpty()
      countryId: ObjectID;
  
  }
  </code></pre>
  
  <p>find code(select all state)</p>
  
  <pre><code> let stateRepository: StateRepository = getCustomRepository(StateRepository);
          try {
  const states = await stateRepository.aggregate([
                  {
                      $lookup:
                      {
                          from: 'country',
                          localField: 'countryId',
                          foreignField: '_id',
                          as: 'country'
                      }
                  }
              ]);
              res.status(200).send({
                  data: states
              });
       }
          catch (exception) {
              res.status(500).send({
                  error: exception,
              });
          }
      }
  </code></pre>
  
  <p>Output:- receive 500 with no error</p>
  
  <pre><code>{
      "error": {}
  }
  </code></pre>