Projections, queries, and ID's

Hi, we are evaluating this
product for use in an enterprise environment and I have a few questions.

We are initially looking
to capture, store and query Audit events and I am wondering if the Event Store
has that capability/ most notably the ability to retrieve the data from the
streams based on criteria from the event. Would the Metadata be of good use in
this scenario? Are projections used to retrieve this data? Do you have
documentation on the creation and use of projections?

I am also curious about aggregateId
and version in general event sourcing. Are these values maintained via a mechanism
within the Event Store, or do they need to be maintained by the application? Is
the EventId within the IEvent interface simply a unique value per event or per
event type?




You can either read streams directly, or use projections to split based on criteria. Currently the documentation on projections isn’t great, we’re hoping to improve it over time. However, as an example, if you have events which you want to access via different streams depending on the value of some property you can use something along the lines of:


function(state, event) {

if (event.someProperty == ‘someValue’)

linkTo(‘myStream’, event);

return state;



Which will give a stream of all the events where someProperty = someValue on a stream called myStream.

In answer to your second question, the Event Store is independent of the DDD concept of aggregates, although it fits quite nicely. Generally you’d use one stream per aggregate (helping enforce an aggregate as a consistency boundary), and use the aggregate ID as the stream ID. The EventId on the IEvent interface gets assigned internally by the Event Store and is a Guid which can be used for things like idempotency etc - it’s unique per event, not per event type.



Is the EventId within the IEvent interface simply a unique value per
event or per event type?

Its per event (Guid)

Hi Ken,

How did you go with this? I’m in the same boat with projections but just starting out. Did you feel the Event Store implementation gave you enough leverage to achieve your store and query of Audit events? Temporal queries over specific events is a big claim, and also projections is still being worked on. How did your experiments in this area go?


  • Wajid


A question to your answer here: The projections you create here would only be possible if the EventStore serialized the events right?


Projections of that form will work if the events are serialized as JSON - the Event Store client works in byte arrays and doesn’t serialize anything for you :slight_smile: