Sorci.js
    Preparing search index...

    Interface SorciNamespace

    interface Sorci {
        appendEvent(payload: AppendEventPayload): Promise<string>;
        close(): Promise<void>;
        createProjection(declaration: ProjectionDeclaration): Promise<void>;
        createStream(): Promise<void>;
        dropAllTestStream(
            payload?: { excludeCurrentStream: boolean },
        ): Promise<void>;
        dropCurrentStream(): Promise<void>;
        dropProjection(name: string): Promise<void>;
        getEventById(id: string): Promise<PersistedEvent | undefined>;
        getEventsByQuery(query: Query): Promise<PersistedEvent[]>;
        insertEvents(events: ToPersistEvent[]): Promise<string[]>;
        queryProjection(
            name: string,
            options?: { where?: Record<string, any> },
        ): Promise<any[]>;
        ready(): Promise<void>;
        refreshProjection(name: string): Promise<void>;
        setEventReducingToProjection(
            payload: {
                eventType: string;
                name: string;
                reducer: EventReducer;
                refreshProjection?: boolean;
            },
        ): Promise<void>;
        setupTestStream(streamName?: string): Promise<void>;
        truncate(): Promise<void>;
        updateProjection(
            payload: {
                alterationSQL: (sql: Sql, tableName: string) => PendingQuery<Row[]>;
                name: string;
            },
        ): Promise<void>;
    }

    Implemented by

    Index

    Projections

    • Drop a projection completely

      Parameters

      • name: string

      Returns Promise<void>

    • Query a projection

      Parameters

      • name: string
      • Optionaloptions: { where?: Record<string, any> }

      Returns Promise<any[]>

    • Manually refresh a projection by reprocessing all events

      Parameters

      • name: string

      Returns Promise<void>

    • Set an event-specific reducer for a projection (adds new or updates existing)

      Parameters

      • payload: {
            eventType: string;
            name: string;
            reducer: EventReducer;
            refreshProjection?: boolean;
        }

      Returns Promise<void>

    • Update an existing projection's schema with custom SQL alterations. Throws if projection doesn't exist.

      Parameters

      • payload: {
            alterationSQL: (sql: Sql, tableName: string) => PendingQuery<Row[]>;
            name: string;
        }

      Returns Promise<void>

    Stream

    • Will append an event with optimistic concurrency control. Uses Dynamic Consistency Boundary (DCB) to detect conflicts without table locks. If queryV2 & lastKnownEventId are provided, it checks if any relevant events were added since lastKnownEventId. If yes, throws a concurrency error.

      Parameters

      Returns Promise<string>

      The event id

    Tooling

    • Will close all database connections Usefull to cleanup after tests

      Returns Promise<void>

    • Will create necessary table

      Returns Promise<void>

    • Will destroy every stream prefixed by 'test-' Usefull to cleanup all test stream

      Parameters

      • Optionalpayload: { excludeCurrentStream: boolean }

      Returns Promise<void>

    • Will drop the current stream Usefull to cleanup a test stream

      Returns Promise<void>

    • Will insert events in the stream without any concurrency check Usefull to setup a test stream with a lot of events

      Parameters

      Returns Promise<string[]>

      An array of event id

    • Wait for instance to finish loading projections from database

      Returns Promise<void>

    • Will create a stream with random name prefixed by 'test-' Usefull to setup a test stream

      Parameters

      • OptionalstreamName: string

      Returns Promise<void>

      You can give a name to the stream if you want to

    • Will remove every events of the stream

      Returns Promise<void>