delete method
Save AggregateState of given aggregate
Implementation
Future<AggregateStateResult<TEvent, TValue, TId, TState>> delete(
TAggregate aggregate) async {
try {
aggregate.ensureExists();
await _events.deleteStream(
StreamName.from(aggregate),
aggregate.expectedVersion,
);
return AggregateStateResult.ok(
current: aggregate.current,
previous: aggregate.original,
);
} on StreamNotFoundException {
return AggregateStateResult.error(
AggregateNotFoundException(
TAggregate,
aggregate.id,
),
aggregate,
);
} on Exception catch (error) {
return AggregateStateResult.error(
error,
aggregate..rollback(),
);
}
}