Ondrej Tomcik
Ondrej Tomcik

Reputation: 1210

Should aggregate model contain metadata?

I would like to clarify, how the model of an aggregate should look like. I have couple of events, which contains data which won't be ever used for validation.

For example, metadata like user_id who triggered the action (auditing), correlation_id (observability), labels / flags.

They will be received within the command and will be sent out as the property of the event. It won't be lost as each event is persisted. That's clear.

But should the aggregate object contain these values? Projection will have them and will display them. Having them in Aggregate does not make sense in my opinion.

Or, it does. In case you want to create the snapshot, you need properties of all events.

Thanks for you advice.

Upvotes: 0

Views: 156

Answers (1)

CPerson
CPerson

Reputation: 1222

Aggregates should contain only as much information as is required to maintain consistency. If your business rules require user_id, then that information should be persisted in the aggregate. Otherwise, it should not.

Upvotes: 1

Related Questions