Closed smilyalexey closed 10 months ago
As far as I understood calling Sequent.aggregate_repository.load_aggregate(event.another_aggregate_id, AnotherAggregate) will return the state of AnotherAggregate not at the moment when this event happened, but at the moment when we run the migration. Am I correct?
Yes that is correct. You can use another method for this : Sequent.aggregate_repository.load_aggregate_for_snapshotting(aggregate_id, AntoherAggregate, event.created_at)
as that will return the state of the aggregate on the moment the event happened.
See https://www.sequent.io/docs/concepts/aggregate-repository.html#loading-aggregateroots.
This will slow down the replaying of a projector considerably though, depending on your use case you could also consider:
Following this https://github.com/zilverline/sequent/issues/383
I have 1 assumption, that this issue may be because of using
Sequent.aggregate_repository.load_aggregate
inside of projectors.For example:
And then
SomethingHappened
is event triggered bySomeAggregate
. But since I want to include some data, located in another aggregate, I need to callaggregate = Sequent.aggregate_repository.load_aggregate(event.another_aggregate_id, AnotherAggregate)
and useaggregate.some_fields
to get this missed data.As far as I understood calling
Sequent.aggregate_repository.load_aggregate(event.another_aggregate_id, AnotherAggregate)
will return the state ofAnotherAggregate
not at the moment when this event happened, but at the moment when we run the migration. Am I correct?