Closed ssipos90 closed 5 years ago
My aggregate looks like this.
cqrs.defineAggregate(
{
name: 'node',
defaultEventPayload: 'payload'
},
{} // default starting data for the aggregate
)
Command is:
require('cqrs-domain').defineCommand(
{
existing: true,
meta: 'meta'
},
({ payload, meta }, aggregate) => aggregate.apply('nodeRenamed', {
...payload,
_meta: meta
})
);
Domain thingy is
require('cqrs-domain')({...})
.defineCommand({
aggregateId: 'aggregate.id',
aggregate: 'aggregate.name',
payload: 'payload',
context: 'context.name',
})
.defineEvent({
name: 'event',
aggregateId: 'aggregate.id',
aggregate: 'aggregate.name',
context: 'context.name',
});
Never mind, I'm stupid and haven't seen that the event is messed up:
require('cqrs-domain').defineEvent(
{
version: 0,
meta: 'meta'
},
(cmd, aggregate) => aggregate.set(cmd.payload)
);
and it should be (note the cb function):
require('cqrs-domain').defineEvent(
{
version: 0,
meta: 'meta'
},
(payload, aggregate) => aggregate.set(payload)
);
I hope I didn't waste anyone's time. Thanks! :)
Hi,
So I was adding a precondition to prevent changing a field of an aggregate to the same value
and guess what? The pre-condition aggregate doesn't have the attributes loaded. The command works fine and if I log something in the callback, it shows.
I've debugged for 3 hours already and I think the issue is in
defaultCommandHandler.js
somewhere withinloadAggregate: function
.What am I missing?