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
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -188,6 +188,42 @@ for await (const event of client.readEvents('/books/42', {
188
188
controller.abort();
189
189
```
190
190
191
+
### Running EventQL Queries
192
+
193
+
To run an EventQL query, call the `runEventQlQuery` function and provide the query as argument. The function returns an asynchronous iterator, which you can use e.g. inside a `for await` loop:
194
+
195
+
```typescript
196
+
forawait (const row ofclient.runEventQlQuery(`
197
+
FROM e IN events
198
+
PROJECT INTO e
199
+
`)) {
200
+
// ...
201
+
}
202
+
```
203
+
204
+
#### Aborting a Query
205
+
206
+
If you need to abort a query use `break` or `return` within the `await for` loop. However, this only works if there is currently an iteration going on.
207
+
208
+
To abort the query independently of that, hand over an abort signal as second argument when calling `runEventQlQuery`, and abort the appropriate AbortController:
209
+
210
+
```typescript
211
+
const controller =newAbortController();
212
+
213
+
forawait (const row ofclient.runEventQlQuery(`
214
+
FROM e IN events
215
+
PROJECT INTO e
216
+
`, controller.signal)) {
217
+
// ...
218
+
}
219
+
220
+
// Somewhere else, abort the controller, which will cause
221
+
// reading to end.
222
+
controller.abort();
223
+
```
224
+
225
+
*Note that each row returned by the iterator matches the projection specified in your query.*
226
+
191
227
### Observing Events
192
228
193
229
To observe all events of a subject, call the `observeEvents` 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.
0 commit comments