简体   繁体   中英

TypeORM - Add extra column when custom column on OneToMany

I want to create a custom column for my @ManyToOne entity. When I have used this code我使用的代码

And the result is: 结果是

There has been added countryId column. What I must to do fix this?

To do this you have to use decorator @RelationId like this:

export class Province {
  //...
  @Column()
  @RelationId((province: Province) => province.country)
  public countryId: number;
}

Please use next time block code with code definition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM