Skip to content

Instantly share code, notes, and snippets.

@briandonahue
Created July 21, 2014 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briandonahue/08dcfacd49ba921e6af6 to your computer and use it in GitHub Desktop.
Save briandonahue/08dcfacd49ba921e6af6 to your computer and use it in GitHub Desktop.
Projection test
// EditionSearchModel,
// NOTE: this sample projection immediately stops in one-time mode unless you have
// either event_type1 or event_type1 events in the store
options({
reorderEvents: true, // enables event reordering in a multi-stream projection
// event reordering attempts to feed the projection with events in a
// their natural order
processingLag: 500, // processing lag in ms allowing event reordering to happen
});
fromStreams(
'$et-EditionCreated',
'$et-EditionOfficePermissionsChanged',
'$et-EditionDescriptionUpdated',
'$et-EditionContactInfoChanged',
'$et-EditionDeactivated',
'$et-EditionDemographicInfoChanged',
'$et-PublicationCategoryChanged'
)
// fromStream('streamId') | fromStreams(['sream1', 'stream2']) | fromCategory('category')
//NOTE: fromCategory requires $by_category standard projection to be enabled
// .foreachStream() | .partitionBy(function(e) { return e.body.useId; })
.when({
$init: function () {
return { }; // initial state
},
$any: function(s, e) {
linkTo('hercules.readmodel-EditionSearchModel', e);
return s;
},
})
// .filterBy(f)/transformBy(f)
// .outputTo(name[, namePattern]) // defines a name for the output stream
//NOTE: filterBy(), transformBy(), emit(), linkTo(), copyTo() require "emit enabled" (see checkbox below)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment