I am trying to update my productDetails table and productMaster table.
here is my relation I have added ,
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 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.
can anyone please help on this. and I am new to typeOrm.
from Not able to update data in one-to-one relation in typeOrm
No comments:
Post a Comment