jerni
a framework to build data-driven products from the ground up

Type:Journey
Namespace:jerni
Extends:Object

Properties

commit:
(UncommittedEvent) => Promise<CommittedEvent>

commits an event to the Events Queue and returns that committed event after it's fully committed

Examples
file: example.js
// t-0: start committing
const event = await journey.commit({
type: "EVENT_1",
payload: {
key: "value",
},
});
console.log(event)

Output

{
id: 10001,
type: "EVENT_1",
payload: {
key: "value"
},
meta: {
/* custom meta data injected by `jerni` */
}
}
waitFor:
(CommittedEvent) => Promise<void>

waits for an event to be fully persisted to all stores of this journey

Examples
file: example.js
// t-0: start committing
const event = await journey.commit({ /* ... */ });
// t-1: event has been written to Events Queue, but hasn't been projected to any store
await journey.waitFor(event)
// t-2: event has been fully projected to all stores
getReader:
([DataModel]) => Promise<NativeReadOnlyDriver>

return a read-only native data querying object depending on the underlaying store

Examples
file: example.js
const { Model } = require('@jerni/store-mongo');
const users = new Model({ /*...*/ });
/* ... */
const UserCollection = await journey.getReader(users);
const someUser = await UserCollection.findOne({ id: '123' });