thenativeweb / node-cqrs-domain

Node-cqrs-domain is a node.js module based on nodeEventStore that. It can be very useful as domain component if you work with (d)ddd, cqrs, eventdenormalizer, host, etc.
http://cqrs.js.org/pages/domain.html
MIT License
269 stars 57 forks source link

Context and aggregateId #142

Closed bikerp closed 5 years ago

bikerp commented 5 years ago

Hi, what is the exact purpose of the context? Fo example can I have two aggregates with the same name (e.g. user) but in different contexts (hr and sales). Can these aggregates use the same aggregateId for the same person e.g. email address?

nanov commented 5 years ago

In short, yes, two aggregates with the same name on different contexts are completely separated, therefore they can ( and probably should ) use the same ID.

As of what is the purpose of context, I suggest you dive into DDD principles to find out.

bikerp commented 5 years ago

Thank you for your answer. I know the DDD and I just wanted to be sure if the context in cqrs-domain means the same.

bikerp commented 5 years ago

I have defined aggreate user in file aggregate.js

module.exports = require('cqrs-domain').defineAggregate({
    name: 'user',
    defaultCommandPayload: 'payload',
    defaultEventPayload: 'payload',
});

I have noticed that aggregate name is not mentioned in event store records. Is it itentional?

nanov commented 5 years ago

It definitely is on the aggregate property.

bikerp commented 5 years ago

You are right. I forgot to put aggregate: 'aggregate.name', into defineEvent Thanks