Skip to content

Commit 494133e

Browse files
authored
Include examples from EventStore.delete_stream/4 in Usage.md
1 parent 6a86dd5 commit 494133e

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

guides/Usage.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,15 @@ You can also pass a list of `event_ids` instead of recorded event structs to lin
161161

162162
There are two ways to delete streams. Soft delete and Hard delete.
163163

164+
Use soft delete when you no longer care about a streams events, but want to preserve the full history of events.
165+
166+
Use hard delete when you want a stream to go away more than a bad case of viral gastroenteritis (for example GDPR compliance).
167+
164168
### Soft delete
165169

166170
Will mark the stream as deleted, but will not delete its events. Events from soft deleted streams will still appear in the globally ordered all events ($all) stream and in any linked streams.
167171

168-
A soft deleted stream cannot be read nor appended to. Subscriptions to the deleted stream will not receive any events.
172+
A soft deleted stream cannot be read nor appended to. Subscriptions to the deleted stream will not receive any events but subscriptions containing linked events from the deleted stream, such as the global all events stream, will still receive events from the deleted stream.
169173

170174
#### Examples
171175

@@ -186,7 +190,7 @@ Delete stream will use soft delete by default so you can omit the type:
186190

187191
### Hard delete
188192

189-
Will permanently delete the stream and its events. This is irreversible and will remove data. Events will be removed from the globally ordered all events ($all) stream and any linked streams.
193+
Will permanently delete the stream and its events. **This is irreversible and will remove data**. Events will be removed from the globally ordered all events ($all) stream and any linked streams.
190194

191195
After being hard deleted, a stream can later be appended to and read as if had never existed.
192196

@@ -204,7 +208,12 @@ Or via config:
204208
config :my_app, MyApp.EventStore, enable_hard_deletes: true
205209
```
206210

207-
Hard delete a stream:
211+
Hard delete a stream at any version:
212+
```elixir
213+
:ok = MyApp.EventStore.delete_stream("stream1", :any_version, :hard)
214+
```
215+
216+
Hard delete a stream that should exist:
208217
```elixir
209218
:ok = MyApp.EventStore.delete_stream("stream2", :stream_exists, :hard)
210219
```

0 commit comments

Comments
 (0)