Hermes MySQL
    Preparing search index...

    Type Alias MySqlEventStore

    MySqlEventStore: EventStore<EventStoreTransaction> & {
        init(): Promise<void>;
        readProjection<State, E extends Event>(
            projection: HermesProjection<State, E>,
            id: string,
            options?: { tx?: EventStoreTransaction },
        ): Promise<{ data: State; version: bigint | null } | null>;
        readStreamVersion(
            streamId: string,
            options?: { tx?: EventStoreTransaction },
        ): Promise<bigint>;
    }

    Type Declaration

    • init: function
      • Creates the missing tables of the projections given to createEventStore (see projectionTable), on its own connection of the pool, never in a transaction: MySQL commits every DDL statement. Existing tables are never changed.

        An append without tx creates the tables of the inline projections before their first use. An append in a transaction of the application (tx) never creates them: it would need a second connection of the pool while the transaction holds one, and a table created after the transaction began cannot be read in it (ER_TABLE_DEF_CHANGED). It throws when they are missing, so call init() on start when you append with tx.

        Returns Promise<void>

    • readProjection: function
      • Reads a document of a projection.

        Type Parameters

        • State
        • E extends Event

        Parameters

        Returns Promise<{ data: State; version: bigint | null } | null>

        The document and, for a single-stream projection, the version of its stream (null for a document fed by many streams); null when there is no document

    • readStreamVersion: function