Overview

The Identity Group is a way of providing a named set of unique Aggregate Identifier records into a query. There are two default groups that are provided for any given aggregate :- "Identity" which provides just one unique aggregate identifier and "All" which provides all the instances of the aggregate.

Other named identity groups can be created for an aggregate which have an attached Projection which defines if any given aggregate identifier is in or out of that group. This group can be cached so that you can pass the group along with an "as at" date so that you can run a query along the lines of "For all the x that were in the group y as of the date z, run the query q"

Each Identity Group has its own underlying event stream with two very simple events in it - an IdentityAdded event which adds the identified aggregate to the list and an IdentityRemoved event which add or remove items from the group. This event stream can be played to regenerate the membership of the group as at any given point in time.

Aggregate_Model_Group.PNG

Example

Suppose you have a model that is a very basic bank account system, with an aggregate identifier for an unique account number. You could create an Identity Group called "Overdrawn accounts" which is populated by a projection that gets the running balance of the account and if that balance is < 0 then adds it to that identity group.

Depending on your business needs you might cache the results of this identity group on an end-of-day basis or dynamically when the group members change. Each cache is time stamped with its "as of" date.

You can then run a query over that identity group by passing in the group's name. The query will then run it's specified projection over every account number currently in that group - but without having to rebuild the group before it is run.

Last edited Nov 2, 2015 at 9:42 PM by Merrion, version 5