Skip to content

Commit

Permalink
* updated the persist function on the gorm event Repository to return…
Browse files Browse the repository at this point in the history
… an error
  • Loading branch information
IshikaGopie committed Jan 23, 2024
1 parent 2e22528 commit 0ee8dbb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion model/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,16 @@ func (e *EventRepositoryGorm) Persist(ctxt context.Context, entity AggregateInte
//call persist on the aggregate root to clear the new changes array
entity.Persist()

var errs []error
for _, entity := range entities {
e.eventDispatcher.Dispatch(ctxt, *entity.(*Event))
errs = e.eventDispatcher.Dispatch(ctxt, *entity.(*Event))
errs = append(errs, errs...)
}

if len(errs) > 0 {
return errs[0]
}

return nil
}

Expand Down

0 comments on commit 0ee8dbb

Please sign in to comment.