Open xlearns opened 1 year ago
@OneToOne
@Entity() export class User { @PrimaryGeneratedColumn() id: number; // ... @OneToOne(() => Profile) @JoinColumn() profile: Profile; }
@Entity() export class Profile { @PrimaryGeneratedColumn() id: number;
// ... }
## n:1 - `@ManyToOne` ## 1:n - `@OneToMany` ## n:n - `@ManyToMany` # [参考](https://github.com/wx-chevalier/Node.js-Notes/blob/f018d971dff6a1c1f4b77cce5d8bd8781cabaabd/03.%E6%A1%86%E6%9E%B6%E4%BD%BF%E7%94%A8/%E6%95%B0%E6%8D%AE%E5%BA%93/TypeORM/%E5%AE%9E%E4%BD%93/%E5%85%B3%E7%B3%BB.md)
关联查询
1:1
@OneToOne
@Entity() export class Profile { @PrimaryGeneratedColumn() id: number;
// ... }