-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Description
Setup:
@Entity()
export Class EntityA extends BaseEntity {
@PrimaryGeneratedColumn()
EntityAId: number;
@Column()
SomeCol: string;
@OneToMany(type => EntityB, entity => entity.EntityA, {
cascadeInsert: true
})
EntityBs: EntityB[];
}
@Entity()
export Class EntityB extends BaseEntity {
@PrimaryGeneratedColumn()
EntityAId: number;
@ManyToOne(type => EntityA, (entity: EntityA) => entity.EntityBs)
@JoinColumn({ name: 'fkEntityA' })
EntityA: EntityA;
}
...
let entity = await EntityA.findOne({
SomeCol: 'SomeVal'
});
entity.EntityBs = [
EntityB.create()
];
entity.save();
Say I already have an EntityA in the database with some EntityBs that reference it.
If I query entityA and then change entity.EntityBs to some new array of EntityBs (and maybe update some existing), the ones that are no longer in the array I want to DELETE from the database.
Right now they only get their fkEntityA reference set to NULL. Is this a feature I can set?
Thanks
(I have tried the cascaseremove on onDelete CASCADE option but the reference record was still just having the value set to NULL)
adenhertog and guscastro
Metadata
Metadata
Assignees
Labels
No labels