Type Alias Publish<Event>Template

Publish<Event>: ((event: Event | Event[], sessionOrCallback?: ClientSession | SaveWithEventCallback) => Promise<void>)

Function to publish an event or events.

Type Parameters

  • Event

Type declaration

    • (event, sessionOrCallback?): Promise<void>
    • Parameters

      • event: Event | Event[]

        An event or events to be sent.

      • OptionalsessionOrCallback: ClientSession | SaveWithEventCallback

        An existing session with which the event(s) should be saved
        or {SaveWithEventCallback} to persist additional data within the callback's session instead.
        If not provided, then the event(s) will be persisted with a new session. Event Type of an event that can be published, e.g type Event = AssignTask | CompleteTask | CreateTask | ....

      Returns Promise<void>

      An empty promise.

await outbox.publish(event, async (session, db) => {
await db.collection('test').insertOne(
{
param: 1,
},
{ session },
)
})