When attempting to insert data based on a specific condition, such as if shopId = "shopA"
, I want to include the shopdetail
. In order to achieve this, I have implemented the following business logic, which is somewhat complex.
Is there a more efficient way to accomplish this task?
request = {
Id:"test",
shopId:"shopA",
element:"testElement"
}
if(request.shopId = "shopA") {
PricingPattern = {
Id:request.Id,
element:request.element,
shopdetail:{
shopId:request.shopId
}
}
} else {
PricingPattern = {
Id:request.Id,
element:request.element
}
}
await getRepository(PricingPattern)
.save([this.pricingPatternInfo])
If you have any suggestions or alternative approaches, please feel free to share them with me.