假设我定义了以下自定义的多对多表,如何通过typeorm api更新?
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@OneToMany(type => UserGroup, userGroup => userGroup.user)
userGroups: UserGroup[];
}
@Entity()
export class UserGroup {
@Column()
isActive: boolean;
@ManyToOne(type => User, user => user.userGroups, { primary: true })
user: User;
@ManyToOne(type => Group, group => group.userGroups, { primary: true })
group: Group;
}
@Entity()
export class Group {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@OneToMany(type => UserGroup, userGroup => userGroup.group)
userGroups: UserGroup[];
}
对于更新自定义多对多表(这是它自己的实体)的说明不多。