Aggregates by date range

hello,

i wanted to ask how to do real time queries for aggregates or filtering the reads?
Within regular database i can just fetch data by date range but i cant get my head around on how to do so in eventstore

Can you explain what this is for? Are you trying to fill a screen or do something else?

@Joao_Braganca so i want to make charts and data tables with sum() avg() for the frontend dashboard. I assume projections are to be used in this case?

That’s one way to do it. However IMO it is better to project this to a SQL database as this is the kind of thing it is good at.

For this kind of work I personally prefer to use Projac to handle the message routing internally.

Here’s how to connect it to event store: https://github.com/BitTacklr/Projac/blob/develop/src/Projac.Recipes/EventStoreIntegration/Usage.cs#L98. It uses the legacy tcp interface not the new grpc interface, and it is subscribing to a single stream when you probably wabt to subscribe to all but the general concept is the same.

And here i show to write to a database: https://github.com/BitTacklr/Projac/blob/develop/src/Projac.Recipes/SQLiteIntegration/Usage.cs. Again this is sqlite but the idea is the same.

Sorry for some reason I assumed you were using c#.

@Joao_Braganca, i’m using nodejs for a backend. I came to the conclusion of not using projections for dashboards and go with redshift or big query. Is there any connector out there for pushing to big query or redshift?

@oblutu not at the moment. You’ll have to write your own subscription to do that. The above examples may be c# but the concept is the same in any language - subscribe to all, route each event to a by type dispatcher - a map where the keys are the event type and the values are a handler function (which in your case would be sql statements), and don’t forget to include the position of the event in the sql so you can recover after a crash.

Check out this blog post: https://www.eventstore.com/blog/event-sourcing-and-cqrs it should help you get started with projecting from your $all stream.