UNPKG

@sekiban/postgres

Version:

PostgreSQL storage provider for Sekiban Event Sourcing framework

31 lines (30 loc) 936 B
import { Pool } from 'pg'; import { ResultAsync } from 'neverthrow'; import { IEvent, IEventStore, EventRetrievalInfo, StorageError } from '@sekiban/core'; /** * PostgreSQL implementation of IEventStore * Implements both IEventReader and IEventWriter interfaces */ export declare class PostgresEventStore implements IEventStore { private pool; constructor(pool: Pool); /** * Initialize the storage provider */ initialize(): ResultAsync<void, StorageError>; /** * Get events based on retrieval information */ getEvents(eventRetrievalInfo: EventRetrievalInfo): ResultAsync<readonly IEvent[], Error>; private doGetEvents; private buildQuery; /** * Save events to storage */ saveEvents<TEvent extends IEvent>(events: TEvent[]): Promise<void>; private doSaveEvents; /** * Close the storage provider */ close(): ResultAsync<void, StorageError>; }