-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use SoftRestorer
?
#40
Comments
Proposal – "Prepare" methodThe package example
func example(repo *repository.Repository) {
var foo aggregate.Aggregate
repo.Prepare(repository.WithSoftDeleted())
repo.Fetch(ctx, foo)
aggregate.Next(foo, "restored", RestoredEvent{})
repo.Save(context.TODO(), foo)
} Drawbacks
|
Proposal – Add specialized methodsThe package example
func example(repo *repository.Repository) {
var foo aggregate.Aggregate
repo.FetchDeleted(ctx, foo)
aggregate.Next(foo, "restored", RestoredEvent{})
repo.Save(context.TODO(), foo)
} Drawbacks
|
Could variadic options not be added to the Proposal - Use variadic optionsThe package example
func example(repo *repository.Repository) {
var foo aggregate.Aggregate // aggregate whose latest event was a SoftDelete => true
repo.Fetch(ctx, foo, repository.WithSoftDeleted(true))
aggregate.Next(foo, "restored", RestoredEvent{})
repo.Save(context.TODO(), foo)
} |
Problem
When the event stream of an aggregate contains a
SoftDeleter
event, the aggregate can neither be queried nor fetched from the aggregate repository. How can an aggregate be restored if it cannot be fetched to raise theSoftRestorer
event?Example
Proposal –
context.Context
APIThe
repository
package could provide a "hidden" API usingcontext.Context.WithValue()
to disable soft-deletion checks:Drawbacks
The text was updated successfully, but these errors were encountered: