Skip to content

Commit 4a558c8

Browse files
chore: adjust readme
1 parent ab63981 commit 4a558c8

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,25 @@ written_events = await client.write_events(
105105

106106
*Note that according to the CloudEvents standard, event IDs must be of type string.*
107107

108+
#### Using the `isEventQlTrue` precondition
109+
110+
If you want to write events depending on an EventQL query, import the `IsEventQlTrue` class and pass it as a list of preconditions in the second argument:
111+
112+
```python
113+
from eventsourcingdb import IsEventQlTrue
114+
115+
written_events = await client.write_events(
116+
events = [
117+
# events
118+
],
119+
preconditions = [
120+
IsEventQlTrue('FROM e IN events WHERE e.type == \'io.eventsourcingdb.library.book-borrowed\' PROJECT INTO COUNT() < 10')
121+
],
122+
)
123+
```
124+
125+
*Note that the query must return a single row with a single value, which is interpreted as a boolean.*
126+
108127
### Reading Events
109128

110129
To read all events of a subject, call the `read_events` function with the subject as the first argument and an options object as the second argument. Set the `recursive` option to `False`. This ensures that only events of the given subject are returned, not events of nested subjects.
@@ -530,4 +549,4 @@ In case you need to set up the client yourself, use the following functions to g
530549
- `get_host()` returns the host name
531550
- `get_mapped_port()` returns the port
532551
- `get_base_url()` returns the full URL of the container
533-
- `get_api_token()` returns the API token
552+
- `get_api_token()` returns the API token

0 commit comments

Comments
 (0)