Skip to content

Commit

Permalink
fix: (cqrs): remove delete metadata when update object with field is …
Browse files Browse the repository at this point in the history
…null
  • Loading branch information
MartinezAvellan committed May 20, 2024
1 parent 6f6c044 commit 9142901
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 34 deletions.
5 changes: 0 additions & 5 deletions components/ledger/internal/app/command/update-account.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ func (uc *UseCase) UpdateAccountByID(ctx context.Context, organizationID, ledger
}

accountUpdated.Metadata = uai.Metadata
} else {
err := uc.MetadataRepo.Delete(ctx, reflect.TypeOf(a.Account{}).Name(), id)
if err != nil {
return nil, err
}
}

return accountUpdated, nil
Expand Down
6 changes: 0 additions & 6 deletions components/ledger/internal/app/command/update-instrument.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ func (uc *UseCase) UpdateInstrumentByID(ctx context.Context, organizationID, led
}

instrumentUpdated.Metadata = uii.Metadata

return instrumentUpdated, nil
}

if err := uc.MetadataRepo.Delete(ctx, reflect.TypeOf(i.Instrument{}).Name(), id.String()); err != nil {
return nil, err
}

return instrumentUpdated, nil
Expand Down
6 changes: 0 additions & 6 deletions components/ledger/internal/app/command/update-ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ func (uc *UseCase) UpdateLedgerByID(ctx context.Context, organizationID, id stri
}

ledgerUpdated.Metadata = uli.Metadata

return ledgerUpdated, nil
}

if err := uc.MetadataRepo.Delete(ctx, reflect.TypeOf(l.Ledger{}).Name(), id); err != nil {
return nil, err
}

return ledgerUpdated, nil
Expand Down
6 changes: 0 additions & 6 deletions components/ledger/internal/app/command/update-organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ func (uc *UseCase) UpdateOrganizationByID(ctx context.Context, id string, uoi *o
}

organizationUpdated.Metadata = uoi.Metadata

return organizationUpdated, nil
}

if err := uc.MetadataRepo.Delete(ctx, reflect.TypeOf(o.Organization{}).Name(), id); err != nil {
return nil, err
}

return organizationUpdated, nil
Expand Down
6 changes: 0 additions & 6 deletions components/ledger/internal/app/command/update-portfolio.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ func (uc *UseCase) UpdatePortfolioByID(ctx context.Context, organizationID, ledg
}

portfolioUpdated.Metadata = upi.Metadata

return portfolioUpdated, nil
}

if err := uc.MetadataRepo.Delete(ctx, reflect.TypeOf(p.Portfolio{}).Name(), id); err != nil {
return nil, err
}

return portfolioUpdated, nil
Expand Down
4 changes: 0 additions & 4 deletions components/ledger/internal/app/command/update-product.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ func (uc *UseCase) UpdateProductByID(ctx context.Context, organizationID, ledger
}

productUpdated.Metadata = upi.Metadata
} else {
if err := uc.MetadataRepo.Delete(ctx, reflect.TypeOf(r.Product{}).Name(), id); err != nil {
return nil, err
}
}

return productUpdated, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type UpdateOrganizationInput struct {
DoingBusinessAs *string `json:"doingBusinessAs,omitempty"`
Address Address `json:"address"`
Status Status `json:"status"`
Metadata map[string]any `json:"metadata,omitempty"`
Metadata map[string]any `json:"metadata"`
}

// Organization is a struct designed to encapsulate response payload data.
Expand Down

0 comments on commit 9142901

Please sign in to comment.