You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The first event generated by an event-sourced aggregate is used to initialize the aggregate instance. The remaining events are applied through methods marked apply.
# Initialize the aggregate with the first event's payload and apply it
aggregate = cls(**events[0].payload)
aggregate._apply(events[0])
# Apply the rest of the events
for event in events[1:]:
aggregate._apply(event)
However, this only works if the first event mirrors the aggregate's attribute structure.
We need to provide a way for aggregates to specify a special method to initialize itself from the first event.
The text was updated successfully, but these errors were encountered:
The first event generated by an event-sourced aggregate is used to initialize the aggregate instance. The remaining events are applied through methods marked
apply
.However, this only works if the first event mirrors the aggregate's attribute structure.
We need to provide a way for aggregates to specify a special method to initialize itself from the first event.
The text was updated successfully, but these errors were encountered: