Aggregate Id problem

We have the following Aggregates:

  • Product
  • Store
  • Stock

The problem we have, is when a Product is created, our backend code creates a Stock Aggregate (which references the Product).

The Product is linked to a Store.

When the customer needs to make a Stock adjustment, they only have the Product Id and Store Id available.

Could anyone a suggest a way we can use Event Store to perform a lookup for the Stock Aggregate?

At the moment we have considered the following:

  1. Table in MySql to hold the relationship (having another de[dependency, especially outside ES is not desirable)
  2. Somehow use a projection when the Stock is created which holds a Product Id and Store Id (not sure how well this will scale though)
  3. Create a hybrid Stock Id from the Product id and Store Id (could we really guarantee this was unique)


3 sounds fine to me.

I have a similar aggregate, but the ’store’ in an entity and the AR use the same id as the product. (I have a prefix on the id, so I can have multiple aspects of products as separate streams). If you have very high volumes there might be contention on that aggregate, but most updates are async anyway…