cqrs icon indicating copy to clipboard operation
cqrs copied to clipboard

Build queries from more than 1 aggregate

Open carlos-verdes opened this issue 5 months ago • 0 comments

If we apply CQRS the commands and queries have different models, and it will be super normal to consume more than one Aggregate event for a single Query.

Simplified example for trading platform:

  • aggregate to manage user portfolio --> allow user to track assets, events like AssetDeposited, AssetWithdrawn, AssetBought, AssetSold
  • aggregate to update prices --> it will register all assets from all users portfolios and every hour will get last price
  • portfolio overview query --> combining the balance of assets of a user (using events from first aggregate) and the update in price (using second aggregate) will show total usd value per portfolio/asset to final user

Related with #94

carlos-verdes avatar Aug 30 '24 05:08 carlos-verdes