Thursday, April 24, 2014

Creating Projections in GetEventStore

Why do you need to create projections? Well currently Im trying to debug a problem and need to find out everything that happened to an order that was placed. I know the Id of the order and want to search the entire GetEventStore and find out everything about it.

GetEventStore: Projections Tab
Note: To be able to access this, you must turn on runProjections=true in the GES config file.

Step 1: Click on New Projection

Delete the code in the Source. Add your Javascript. For Example, I had to go through the entire GES to search for an event where Id == 69864709-5991-49CF-8283-65E99AB343A2 (Guid)


fromStream('Test-events') 
    .when({
        $init: function () {
            return { count: 0, }; // initial state
        },
      
        OrderModified: function(s, e) {
            if(e.body.OrderId.toString() == 'a88b484d-e208-44c4-afd0-2ea1d76838cd'){
                linkTo('OrderId-a88b484d', e);
            }
        },
    }); 

2 Click on Emit Enable
3 Post. Now your Projection shows up in the Streams for analysis.

No comments: