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);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With