UNPKG

@eventstore.net/event.store

Version:

A simple and fast EventStore that support multiple persistence and notification providers

54 lines 1.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * An Event Stream */ class EventStreamImpl { constructor(eventStore, stream) { this.eventStore = eventStore; this.stream = stream; } /** * The event stream identifier * The event stream */ get streamId() { return this.stream.id; } /** * The parent aggregation for this event stream */ get aggregation() { return this.stream.aggregation; } /** * Rertieve a list containing all the events in the stream in order. * @param offset The start position in the stream list * @param limit The desired quantity events * @return All the events */ getEvents(offset, limit) { return this.getProvider().getEvents(this.stream, offset, limit); } /** * Add a new event to the end of the event stream. * @param data The event data * @param type The Event type * @return The event, updated with informations like its sequence order and commitTimestamp */ async addEvent(data, type) { const addedEvent = await this.getProvider().addEvent(this.stream, data, type); if (this.eventStore.publisher) { await this.eventStore.publisher.publish({ event: addedEvent, stream: this.stream }); } return addedEvent; } getProvider() { return this.eventStore.provider; } } exports.EventStreamImpl = EventStreamImpl; //# sourceMappingURL=event-stream.js.map