In J Oliver's EventStore how should i be using the streamId when opening a stream?
Should I have a new stream/streamid for each object/aggregate root object?
So should my order state objects which i think should be ar objects each have a streamid?
In J Oliver's EventStore how should i be using the streamId when opening a stream?
Should I have a new stream/streamid for each object/aggregate root object?
So should my order state objects which i think should be ar objects each have a streamid?
The StreamId is your Aggregate Root Id. You probably want to include it in your Commands. Since they are Guids, you can set them before you send the command from the client which means that you can act upon the same AR without having to load it from the read model.
Here is an example using the CommonDomain project:
class CreateOrder {
public Guid OrderId;
...
}
class CreateOrderHandler {
void Handle(command) {
var order = Order.Create(command.OrderId);
// This is using the Id property from AggregateBase in CommonDomain
repository.Save(order, Guid.NewGuid(), null);
}
}
© 2022 - 2024 — McMap. All rights reserved.