modernice / goes

goes is an event-sourcing framework for Go.
https://goes.modernice.dev
Apache License 2.0
134 stars 12 forks source link

Soft Deletes #22

Closed bounoable closed 2 years ago

bounoable commented 2 years ago

The builtin command to delete an aggregate deletes all events of an aggregate from the event store (useful to comply with GDPR). Normally, we don't want to actually delete events from the event store but instead publish an event that "marks" the aggregate as deleted and prevents it from being queryable without losing all the aggregate events.

Proposal

User-defined events may provide a SoftDelete() bool method that the aggregate repository will use within a query or fetch to determine if an aggregate has been soft-deleted. Within a query, a soft-deleted aggregate is simply excluded from the query result. Within a fetch, a new repository.ErrDeleted error will be returned. In order to revert the deletion (or "restore" the aggregate), events may provide a SoftRestore() bool method that "restores" the aggregate to include it in query results and to re-allow to fetch the aggregate.