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: README.md
+47-47Lines changed: 47 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,23 @@
1
-
# eventsourcingdb
1
+
# EventSourcingDB
2
2
3
-
The official Elixir client SDK for [EventSourcingDB](https://www.eventsourcingdb.io) – a purpose-built database for event sourcing.
3
+
The official Elixir client SDK for [EventSourcingDB](https://www.EventSourcingDB.io) – a purpose-built database for event sourcing.
4
4
5
5
EventSourcingDB enables you to build and operate event-driven applications with
6
6
native support for writing, reading, and observing events. This client SDK
7
-
provides convenient access to its capabilities in Elixir (read the [Elixir SDK documentation](https://hexdocs.pm/eventsourcingdb)).
7
+
provides convenient access to its capabilities in Elixir (read the [Elixir SDK documentation](https://hexdocs.pm/EventSourcingDB)).
8
8
9
-
For more information on EventSourcingDB, see its [official documentation](https://docs.eventsourcingdb.io/).
9
+
For more information on EventSourcingDB, see its [official documentation](https://docs.EventSourcingDB.io/).
10
10
11
11
This client SDK includes support for [Testcontainers](https://testcontainers.com/) to spin up EventSourcingDB instances in integration tests. For details, see [Using Testcontainers](#using-testcontainers).
12
12
13
13
## Getting Started
14
14
15
-
The package can be installed by adding `eventsourcingdb` to your list of dependencies in `mix.exs`:
15
+
The package can be installed by adding `EventSourcingDB` to your list of dependencies in `mix.exs`:
Now every request will take the client as its first param.
@@ -38,15 +38,15 @@ Now every request will take the client as its first param.
38
38
Call the `write_events` function and hand over a list with one or more events. You do not have to provide all event fields – some are automatically added by the server.
39
39
40
40
Specify `source`, `subject`, `type`, and `data` according to the
written =Eventsourcingdb.write_events(client, [event])
59
+
written =EventSourcingDB.write_events(client, [event])
60
60
61
61
case written do
62
62
{:ok, events} -># ...
@@ -69,10 +69,10 @@ end
69
69
If you only want to write events in case a subject (such as `/books/42`) does not yet have any events, use the `IsSubjectPristine` precondition to create a precondition and pass it in a vector as the second argument:
If you only want to write events in case a subject (such as `/books/42`) already has at least one event, use the `IsSubjectPopulated` precondition to create a precondition and pass it in a vector as the second argument:
If you only want to write events in case the last event of a subject (such as `/books/42`) has a specific ID (e.g., `0`), use the `IsSubjectOnEventId` precondition to create a precondition and pass it in a vector as the second argument:
If you want to write events depending on an EventQL query, use the `IsEventQLQueryTrue` precondition to create a precondition and pass it in a vector as the second argument:
123
123
124
124
```elixir
125
-
written =Eventsourcingdb.write_events(
125
+
written =EventSourcingDB.write_events(
126
126
client,
127
127
[event],
128
-
[%Eventsourcingdb.IsEventQLQueryTrue{
128
+
[%EventSourcingDB.IsEventQLQueryTrue{
129
129
query:"FROM e IN events WHERE e.type == 'io.eventsourcingdb.library.book-borrowed' PROJECT INTO COUNT () < 10"
130
130
}]
131
131
)
@@ -144,7 +144,7 @@ subject and an options object.
144
144
The function returns a stream from which you can retrieve one event at a time:
145
145
146
146
```elixir
147
-
result =Eventsourcingdb.read_events(client, "/books/42")
147
+
result =EventSourcingDB.read_events(client, "/books/42")
148
148
149
149
case result do
150
150
{:ok, events} ->Enum.to_list(events)
@@ -157,10 +157,10 @@ end
157
157
If you want to read not only all the events of a subject, but also the events of all nested subjects, set the `recursive` option to `true`:
@@ -169,10 +169,10 @@ result = Eventsourcingdb.read_events(
169
169
By default, events are read in chronological order. To read in anti-chronological order, provide the `order` option and set it using the `:antichronological` ordering:
170
170
171
171
```elixir
172
-
result =Eventsourcingdb.read_events(
172
+
result =EventSourcingDB.read_events(
173
173
client,
174
174
"/books/42",
175
-
%Eventsourcingdb.ReadEventsOptions{
175
+
%EventSourcingDB.ReadEventsOptions{
176
176
recursive:false,
177
177
order::antichronological
178
178
}
@@ -188,16 +188,16 @@ Sometimes you do not want to read all events, but only a range of events. For th
188
188
Specify the ID and whether to include or exclude it, for both the lower and upper bound:
189
189
190
190
```elixir
191
-
result =Eventsourcingdb.read_events(
191
+
result =EventSourcingDB.read_events(
192
192
client,
193
193
"/books/42",
194
-
%Eventsourcingdb.ReadEventsOptions{
194
+
%EventSourcingDB.ReadEventsOptions{
195
195
recursive:false,
196
-
lower_bound: %Eventsourcingdb.BoundOptions{
196
+
lower_bound: %EventSourcingDB.BoundOptions{
197
197
type::inclusive,
198
198
id:"100"
199
199
},
200
-
upper_bound: %Eventsourcingdb.BoundOptions{
200
+
upper_bound: %EventSourcingDB.BoundOptions{
201
201
type::exclusive,
202
202
id:"200"
203
203
}
@@ -212,12 +212,12 @@ To read starting from the latest event of a given type, provide the `from_latest
212
212
Possible options are `:read_nothing`, which skips reading entirely, or `:read_everything`, which effectively behaves as if `from_latest_event` was not specified:
@@ -233,7 +233,7 @@ result = Eventsourcingdb.read_events(
233
233
To run an EventQL query, call the `run_eventql_query` function and provide the query as argument. The function returns a stream.
234
234
235
235
```elixir
236
-
result =Eventsourcingdb.run_eventql_query(client, "FROM e IN events PROJECT INTO e")
236
+
result =EventSourcingDB.run_eventql_query(client, "FROM e IN events PROJECT INTO e")
237
237
238
238
case result do
239
239
{:ok, events} ->Enum.to_list(events)
@@ -248,7 +248,7 @@ To observe all events of a subject, call the `observe_events` function with the
248
248
The function returns a stream from which you can retrieve one event at a time:
249
249
250
250
```elixir
251
-
result =Eventsourcingdb.observe_events(client, "/books/42")
251
+
result =EventSourcingDB.observe_events(client, "/books/42")
252
252
253
253
case result do
254
254
{:ok, events} ->Enum.to_list(events)
@@ -261,10 +261,10 @@ end
261
261
If you want to observe not only all the events of a subject, but also the events of all nested subjects, set the `recursive` option to `true`:
262
262
263
263
```elixir
264
-
result =Eventsourcingdb.observe_events(
264
+
result =EventSourcingDB.observe_events(
265
265
client,
266
266
"/books/42",
267
-
%Eventsourcingdb.ObserveEventsOptions{
267
+
%EventSourcingDB.ObserveEventsOptions{
268
268
recursive:true
269
269
}
270
270
)
@@ -281,12 +281,12 @@ Sometimes you do not want to observe all events, but only a range of events. For
281
281
Specify the ID and whether to include or exclude it:
282
282
283
283
```elixir
284
-
result =Eventsourcingdb.observe_events(
284
+
result =EventSourcingDB.observe_events(
285
285
client,
286
286
"/books/42",
287
-
%Eventsourcingdb.ObserveEventsOptions{
287
+
%EventSourcingDB.ObserveEventsOptions{
288
288
recursive:false,
289
-
lower_bound: %Eventsourcingdb.BoundOptions{
289
+
lower_bound: %EventSourcingDB.BoundOptions{
290
290
type::inclusive,
291
291
id:"100"
292
292
}
@@ -301,12 +301,12 @@ To observe starting from the latest event of a given type, provide the `from_lat
301
301
Possible options are `:wait_for_event`, which waits for an event of the given type to happen, or `:read_everything`, which effectively behaves as if `from_latest_event` was not specified:
To list all subjects, call the `list_subjects` function with `/` as the base subject. The function returns a stream from which you can retrieve one subject at a time:
348
348
349
349
```elixir
350
-
result =Eventsourcingdb.read_subjects(client, "/")
350
+
result =EventSourcingDB.read_subjects(client, "/")
351
351
352
352
case result do
353
353
{:ok, subjects} ->Enum.to_list(subjects)
@@ -358,15 +358,15 @@ end
358
358
If you only want to list subjects within a specific branch, provide the desired base subject instead:
359
359
360
360
```elixir
361
-
result =Eventsourcingdb.read_subjects(client, "/books")
361
+
result =EventSourcingDB.read_subjects(client, "/books")
362
362
```
363
363
364
364
## Reading a Specific Event Type
365
365
366
366
To list a specific event type, call the `read_event_type` function. The function returns the detailed event type, which includes the schema:
367
367
368
368
```elixir
369
-
result =Eventsourcingdb.read_event_types(client, "io.eventsourcingdb.library.book-acquired")
369
+
result =EventSourcingDB.read_event_types(client, "io.eventsourcingdb.library.book-acquired")
370
370
371
371
case result do
372
372
{:ok, event_types} ->Enum.to_list(event_types)
@@ -390,7 +390,7 @@ Then you are ready to use the provideded `TestContainer` in your tests:
0 commit comments