Comments (8)
yes, you can pass extra infos via command.meta to the event
from node-cqrs-domain.
Is there any other way to achieve this??
i mean inside domain.defineCommand()
i want to use my custom method to append data to event.. here is my code structure..
module.exports = require('cqrs-domain').defineCommand({
name: 'createNarration',
payload: 'payload'
}, function (data, aggregate) {
require('/path/to/myfile.js').append(data, "createNarration", function(err, res){
if(err){
cosnole.log(err);
}else{
// Not working :Type Error is generated..
aggregate.apply('narrationCreated', data);
}
});
})
If my code structure is like below, its working fine..
module.exports = require('cqrs-domain').defineCommand({
name: 'createNarration',
payload: 'payload'
}, function (data, aggregate) {
//Working fine but i want to append info to data..
aggregate.apply('narrationCreated', data);
})
But i am using my custom method to fill data before event created. Though data
is filled with my custom info but,
The problem here i am facing is after appending data to events ,aggregate.apply
can not apply data to event ..
Error is like
aggregate.apply('narrationCreated', data);
^
TypeError: Object #<Object> has no method 'apply'
at /home/vishant/Documents/cqrs-sample-vishant/domain/domainFiles/masters/narration/commands/createNarration.js:12:23
at module.exports.append (/home/vishant/BizOs/bizosprojects/commonfeatures/eventdenormalizerservice/utility/commandappenderutil.js:155:13)
at _asyncMap (/home/vishant/BizOs/bizosprojects/commonfeatures/node_modules/async/lib/async.js:254:17)
at async.eachSeries.iterate (/home/vishant/BizOs/bizosprojects/commonfeatures/node_modules/async/lib/async.js:157:25)
at _asyncMap (/home/vishant/BizOs/bizosprojects/commonfeatures/node_modules/async/lib/async.js:251:21)
at async.series.results (/home/vishant/BizOs/bizosprojects/commonfeatures/node_modules/async/lib/async.js:615:34)
at module.exports.append.async.series.data.error (/home/vishant/BizOs/bizosprojects/commonfeatures/eventdenormalizerservice/utility/commandappenderutil.js:150:17)
at async.series.results (/home/vishant/BizOs/bizosprojects/commonfeatures/node_modules/async/lib/async.js:610:21)
at _asyncMap (/home/vishant/BizOs/bizosprojects/commonfeatures/node_modules/async/lib/async.js:249:17)
at async.eachSeries.iterate (/home/vishant/BizOs/bizosprojects/commonfeatures/node_modules/async/lib/async.js:149:13)
Process finished with exit code 8
_F.Y.I. aggregate object has all the attribute & methods except 1 that is apply
method_
from node-cqrs-domain.
This is what i was trying to say.. I have replicate the issue ..
I have added a custom function to your cqrs-sample project.. Below is my commit to your repo..
vishant-dhandha/cqrs-sample@20a0f24
Here i have added async http call to fetch some info & append to the 'data'..
At aggregate.apply('itemCreated', data);
data contains my desired info but some how server stopped with TypeError: Object #Object has no method 'apply'
from node-cqrs-domain.
this is not possible... the whole apply part is completely sync...
can't you extend your command before it enters the domain.handle?
from node-cqrs-domain.
I want to make a async call, if that async call successfully returned then and then only the event should be generated.
How could i make out this?
Saga is the solution for that???
from node-cqrs-domain.
asynccall(function (err, extenstion) {
if (!err) {
command.myExtension = extension;
domain.handle(command);
}
});
from node-cqrs-domain.
I have an idea:
Would it be ok for you, if you define a precondition for that command in which you make your async requests and save the resulting data in a sort of clipboard on the aggregate and afterwards in de command just get that saved data and extend your event?
from node-cqrs-domain.
Yes , this (precondition) solved my problem..
thank you
from node-cqrs-domain.
Related Issues (20)
- Let MongoDB generate the aggregate ID? HOT 6
- Is it possible to replace the t4-validation? HOT 5
- CQRS Question about bulk import HOT 5
- revision guard HOT 6
- [Bug] Precondition aggregate is empty HOT 2
- How to use in AWS Lambda HOT 5
- Can a command fire more than one event? HOT 3
- Access meta in command HOT 2
- How to use domainPath in unit tests HOT 7
- Context and aggregateId HOT 5
- defaultCommandHandler bug, adding "undefined" to array of evtsToDispatch HOT 1
- How to clear/init HOT 2
- Same event name in different contexts HOT 2
- default value command schema HOT 2
- Where to catch Error: Please pass a valid aggregate id! HOT 11
- Transaction with two aggregates HOT 1
- How to handle errors thrown from defineCommand / defineEvent handlers? HOT 9
- Unique field validation HOT 7
- rollback aggregate to a given revision HOT 5
- Update deps HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-cqrs-domain.