Closed bikerp closed 5 years ago
Sure, you could do something like that ( ES6 syntax, assuming your payload is defined at payload
and metadata at metadata
) :
module.exports = require('cqrs-domain').defineCommand({
name: 'enterNewPerson',
version: 1,
payload: '',
// ... whatever else you might need
}, ({ payload, metadata }, aggregate) => {
if (metadata.something)
aggregate.apply('metadataDependantEvent', { my: 'eventPayload' });
aggregate.apply('enteredNewPerson', payload);
});
Thanks, the payload: '',
did the trick.
Hi, is it possible to access meta in command? Thanks