Issues with projections

I’m playing around with Event Store and got to projections but I can’t get them to work.

I ended up deleting my db and re-creating to see how built in projections behave. I enabled them all before I started pushing data in.

Issue 1 is that whenever I look at built in projection I get a screen with what seems to be missing data -

I insert a pile of events (like AddedLineItemToBasketEvent) for streams like ‘basket-10’ and so on. I can see all the baskets and all events in Stream Browser.

When I tried to create my own projections they were always empty so I looked at built in ones -

by event type -

Data

{
  "handlerType": "native:EventStore.Projections.Core.Standard.IndexEventsByEventType",
  "query": "",
  "mode": "Continuous",
  "enabled": true,
  "sourceDefinition": {
    "allEvents": true,
    "allStreams": true,
    "categories": [],
    "events": [],
    "streams": [],
    "options": {
      "definesFold": true
    }
  },
  "emitEnabled": true,
  "checkpointsDisabled": false,
  "epoch": -1,
  "version": 1,
  "runAs": {
    "name": "$system"
  }
}

by Category -
**Data**

{
“handlerType”: “native:EventStore.Projections.Core.Standard.CategorizeEventsByStreamPath”,
“query”: “first\r\n-”,
“mode”: “Continuous”,
“enabled”: true,
“sourceDefinition”: {
“allEvents”: true,
“allStreams”: true,
“categories”: [],
“events”: [],
“streams”: [],
“options”: {
“definesFold”: true,
“includeLinks”: true
}
},
“emitEnabled”: true,
“checkpointsDisabled”: false,
“epoch”: -1,
“version”: 1,
“runAs”: {
“name”: “$system”
}
}

and so on, they all seem to have empty arrays in them. Am I missing something obvious here? I figure default projections should have my [“basket”] in categories and [“AddedLineItemToBasketEvent”] in events or some such?

Thanks.

So internal projections don’t have bodies (they are implemented internally).

The internal projections such as by category and by event type write to streams eg $et-{eventtype} as indexes.

Greg

Thanks! I guess I’m just confused about the UI part.

I added a simple projection -

fromCategory(‘basket’)

.foreachStream()

.when({

“$init”: function(state, ev) {

return { count: 0 }

},

“AkkaEventStore.Actors.AddedLineItemToBasketEvent”: function(state, ev) {

state.count++

}

})

and wanted to see if I could get some data by using the UI but couldn’t figure out how.

http://127.0.0.1:2113/projection/Test/state?partition=basket-161 does seem to give me what I wanted though.

As I was writing this I added another projection

fromCategory(‘basket’)

.when({

“$init”: function(state, ev) {

return { count: 0 }

},

“AkkaEventStore.Actors.AddedLineItemToBasketEvent”: function(state, ev) {

state.count++

}

})

removed foreachStream and now Results and State show things in UI.

I get it, if a projection has a ‘singleton’ state then UI will show it, if it has multiple states (per stream) then it won’t show anything.

Thanks again!