I am trying to update my productDetails table and productMaster table.
Here is my relation:
ProductMaster.ts:
@OneToOne(type => ProductDetails, productDetails => productDetails.productMaster,{
cascade: ["insert", "update"]
})
productDetails: ProductDetails;
ProductDetails.ts:
@OneToOne(type => ProductMaster, productMaster => productMaster.productDetails,{
cascade: ["insert", "update"]
})
@JoinColumn({name: 'prd_id', referencedColumnName: 'prd_id'})
productMaster: ProductMaster;
Now I have to update my productMaster and productDetails using TypeORM relations.
Here is what I tried:
productMasterRepository
.createQueryBuilder()
.update()
.set({
prd_name : 'my Product Name'
productDetails : {
prd_brand : 'My Product Brand Name'
}
})
.where("prd_id = :prd_id", {prd_id: 1})
.execute();
But it doesn't update.