Skip to content

Commit 2f95e66

Browse files
committed
fix: Add documentation on writing events.
1 parent fbc8407 commit 2f95e66

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,26 @@ If you want to verify the API token, call `verifyApiToken`. If the token is inva
3232
```typescript
3333
await client.verifyApiToken();
3434
```
35+
36+
### Writing Events
37+
38+
Call the `writeEvents` function and hand over an array with one or more events. You do not have to provide all event fields – some are automatically added by the server.
39+
40+
Specify `source`, `subject`, `type`, and `data` according to the [CloudEvents](https://docs.eventsourcingdb.io/fundamentals/cloud-events/) format.
41+
42+
The function returns the written events, including the fields added by the server:
43+
44+
```typescript
45+
const writtenEvents = await client.writeEvents([
46+
{
47+
source: 'https://library.eventsourcingdb.io',
48+
subject: '/books/42',
49+
type: 'io.eventsourcingdb.library.book-acquired',
50+
data: {
51+
title: '2001 – A Space Odyssey',
52+
author: 'Arthur C. Clarke',
53+
isbn: '978-0756906788'
54+
}
55+
}
56+
]);
57+
```

0 commit comments

Comments
 (0)