0

I try to update a projection from event store. The following line will load all events:

$events = $this->eventStore->load(new StreamName('mystream'));

Currently i try to load only not handled events by passing the fromNumber parameter:

$events = $this->eventStore->load(new StreamName('mystream'), 10);

This will load all events eg from 15 to 40. But i found no way to figure out which is the current/highest "no" of the results. But this is necessary for me to load only from this entry on the next time.

If the database is truncated (with restarted sequences) this is not a real problem cause i know that the events will start with 1. But if the primary key starts with a number higher than 1 can not figure out which event has which number in the event store

nblum
  • 155
  • 1
  • 1
  • 6

1 Answers1

1

When you are using pdo-event-store, you have a key _position in the event metadata after loading, so your read model can track which position was the last you were working on. Other then that, if you are working with proophs event-store projections, you don't need to take care of that at all. The projector will track the current event position for all needed streams internally, you just need to provide callbacks for each event where you need to do something.

  • I use the `\Prooph\EventStore\Pdo\PostgresEventStore` and the event meta data is: _aggregate_id = "e0778d9f-81de-4326-b95e-96ae51532ad5" _aggregate_type = "employee" _aggregate_version = 1 so there is no _position i my case – nblum Nov 15 '17 at 14:01
  • Please check those lines of code and debug, raise an github issue if needed: https://github.com/prooph/pdo-event-store/blob/master/src/PdoStreamIterator.php#L119-L121 – Sascha-Oliver Prolic Nov 17 '17 at 06:44
  • My mistake i used v1.0.0 of the pdo-event-store. It's working now with 1.5.3 – nblum Nov 24 '17 at 10:03