Query a stream from a given event #?

I’m trying to wrap my head around snapshots. It is my understanding that the proposed solution is to publish a snapshot to a separate stream.

My two questions are:

  1. How do I know which event # the snapshot if of?

  2. How do I query a stream starting with a given event number?

I am using HTTP api.

Example:

Consider an account #123, with some events:

A1: “account created”,

A2: “deposited $20”

A3: “withdrawn $10”

This would be published to “streams/account-123.”

I want to create a snapshot after A2. Would I push an event to “streams/account-snapshot-123” that looks something like this?:

{balance: 20, seq_number: 2}

How do I then query “streams/account-123” for events starting after the 2nd one only?

  • How do I know which event # the snapshot is of?

I guess I keep my own counter, and always post with “ExpectedVersion”.

1. How do I know which event # the snapshot if of?

Its the one you read until when making the snapshot.

2. How do I query a stream starting with a given event number?

http://127.0.0.1:2113/streams/{streamname}/{eventnumber}/forward/{count}