You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: railseventstore.org/source/docs/expected_version.html.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ There are 3 values that you can use for providing `expected_version` when publis
5
5
## :any
6
6
7
7
```ruby
8
-
event_store.publish_event(
8
+
event_store.publish(
9
9
event,
10
10
stream_name:"Order-1",
11
11
expected_version::any,
@@ -32,7 +32,7 @@ event_store.publish_event(
32
32
You start by publishing the first event in a stream with `expected_version` being `-1` (or `:none`). That means you expect no events in the stream right now.
33
33
34
34
```ruby
35
-
event_store.publish_event(
35
+
event_store.publish(
36
36
event0,
37
37
stream_name:"Order-1",
38
38
expected_version:-1, # or :none which is a synonym
@@ -43,7 +43,7 @@ event_store.publish_event(
43
43
The first published event is at position `0`. When you publish a second event you provide `expected_version: 0`.
44
44
45
45
```ruby
46
-
event_store.publish_events(
46
+
event_store.publish(
47
47
[event1, event2],
48
48
stream_name:"Order-1",
49
49
expected_version:0,
@@ -53,7 +53,7 @@ event_store.publish_events(
53
53
We published the second and third events. Their positions are `1` and `2`. That's why when you publish the next event you need to provide `expected_version: 2`.
54
54
55
55
```ruby
56
-
event_store.publish_event(
56
+
event_store.publish(
57
57
event3,
58
58
stream_name:"Order-1",
59
59
expected_version:2,
@@ -81,7 +81,7 @@ This mode effectively acts as optimistic locking.
81
81
## :auto
82
82
83
83
```ruby
84
-
event_store.publish_event(
84
+
event_store.publish(
85
85
event,
86
86
stream_name:"Order-1",
87
87
expected_version::auto,
@@ -95,7 +95,7 @@ There is a potential for a race condition between reading the `expected_version`
0 commit comments