Skip to content

Commit 4e6ac31

Browse files
kurrentdb
1 parent 71dede1 commit 4e6ac31

File tree

2 files changed

+36
-34
lines changed

2 files changed

+36
-34
lines changed

docs/modules/kurrentdb.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# KurrentDB Module
2-
3-
[KurrentDB](https://kurrent.io) is an event sourcing database that stores data in streams of immutable events.
1+
# KurrentDB
42

53
## Install
64

@@ -10,10 +8,22 @@ npm install @testcontainers/kurrentdb --save-dev
108

119
## Examples
1210

11+
These examples use the following libraries:
12+
13+
- [@kurrent/kurrentdb-client](https://www.npmjs.com/package/@kurrent/kurrentdb-client)
14+
15+
npm install @kurrent/kurrentdb-client
16+
17+
Choose an image from the [container registry](https://hub.docker.com/r/kurrentplatform/kurrentdb) and substitute `IMAGE`.
18+
19+
### Execute a query
20+
1321
<!--codeinclude-->
14-
[Start container:](../../packages/modules/kurrentdb/src/kurrentdb-container.test.ts) inside_block:startContainer
22+
[](../../packages/modules/kurrentdb/src/kurrentdb-container.test.ts) inside_block:startContainer
1523
<!--/codeinclude-->
1624

25+
### Subscribe to a standard projection
26+
1727
<!--codeinclude-->
18-
[Subscribe to standard projection:](../../packages/modules/kurrentdb/src/kurrentdb-container.test.ts) inside_block:usingStandardProjections
28+
[](../../packages/modules/kurrentdb/src/kurrentdb-container.test.ts) inside_block:usingStandardProjections
1929
<!--/codeinclude-->

packages/modules/kurrentdb/src/kurrentdb-container.test.ts

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { KurrentDbContainer } from "./kurrentdb-container";
55
const IMAGE = getImage(__dirname);
66

77
describe.sequential("KurrentDbContainer", { timeout: 240_000 }, () => {
8-
// startContainer {
98
it("should execute write and read", async () => {
9+
// startContainer {
1010
await using container = await new KurrentDbContainer(IMAGE).start();
1111

1212
const client = KurrentDBClient.connectionString(container.getConnectionString());
@@ -17,23 +17,17 @@ describe.sequential("KurrentDbContainer", { timeout: 240_000 }, () => {
1717
data: { email: "[email protected]" },
1818
type: "UserCreated",
1919
id: "28ab6bca-d9ae-418b-a1af-eb65dd653c38",
20-
metadata: {
21-
someMetadata: "bar",
22-
},
20+
metadata: { someMetadata: "bar" },
2321
},
2422
]);
2523

2624
expect(await consumeSteamingRead(client.readStream("User-1"))).toEqual([
2725
expect.objectContaining({
2826
event: expect.objectContaining({
29-
data: {
30-
31-
},
27+
data: { email: "[email protected]" },
3228
id: "28ab6bca-d9ae-418b-a1af-eb65dd653c38",
3329
isJson: true,
34-
metadata: {
35-
someMetadata: "bar",
36-
},
30+
metadata: { someMetadata: "bar" },
3731
revision: 0,
3832
streamId: "User-1",
3933
type: "UserCreated",
@@ -42,11 +36,19 @@ describe.sequential("KurrentDbContainer", { timeout: 240_000 }, () => {
4236
]);
4337

4438
await client.dispose();
39+
40+
async function consumeSteamingRead(read: AsyncIterableIterator<unknown>): Promise<unknown[]> {
41+
const events = [];
42+
for await (const event of read) {
43+
events.push(event);
44+
}
45+
return events;
46+
}
47+
// }
4548
});
46-
// }
4749

48-
// usingStandardProjections {
4950
it("should use built-in projections", async () => {
51+
// usingStandardProjections {
5052
await using container = await new KurrentDbContainer(IMAGE).start();
5153
const client = KurrentDBClient.connectionString(container.getConnectionString());
5254

@@ -86,22 +88,12 @@ describe.sequential("KurrentDbContainer", { timeout: 240_000 }, () => {
8688
);
8789
await stream.unsubscribe();
8890
await client.dispose();
91+
92+
async function getStreamFirstEvent(stream: StreamSubscription): Promise<unknown> {
93+
for await (const event of stream) {
94+
return event;
95+
}
96+
}
97+
// }
8998
});
90-
// }
9199
});
92-
93-
async function consumeSteamingRead(read: AsyncIterableIterator<unknown>): Promise<unknown[]> {
94-
const events = [];
95-
96-
for await (const event of read) {
97-
events.push(event);
98-
}
99-
100-
return events;
101-
}
102-
103-
async function getStreamFirstEvent(stream: StreamSubscription): Promise<unknown> {
104-
for await (const event of stream) {
105-
return event;
106-
}
107-
}

0 commit comments

Comments
 (0)