EventStore / EventStore-Client-Go

Go Client for Event Store version 20 and above.
Apache License 2.0
105 stars 27 forks source link

Get stream revision when doing a ReadStream() #148

Closed wiegell closed 10 months ago

wiegell commented 1 year ago

It seems the javascript package has a field for the current stream revision when doing a read:

// From: https://www.eventstore.com/blog/keep-your-streams-short-temporal-modelling-for-fast-reads-and-optimal-data-retention

export async function getStreamRevisionOfTheFirstEvent(
  eventStore: EventStoreDBClient,
  streamName: string
): Promise<bigint> {
  const firstEvent = (
    await readFromStream(eventStore, streamName, {
      maxCount: 1,
      direction: FORWARDS,
      fromRevision: START,
    })
  )[0];

  return firstEvent.streamRevision;
}

The RecordedEvent struct does not have a stream revision, but only EventNumber. Can those be used interchangeably? If so, it could be better documented IMO.

YoEight commented 1 year ago

@wiegell Yes they are I agree this should be amended.