Closed pawarvijay closed 8 years ago
Yes, but you really need a context and aggregate definition file like: https://github.com/adrai/node-cqrs-domain/blob/master/test/integration/fixture/set1/hr/context.js and: https://github.com/adrai/node-cqrs-domain/blob/master/test/integration/fixture/set1/hr/person/aggregate.js
1 : do i also need to structure + configure viewbuilder folder for my context ...?
2 : i found these references for viewBuilder.
If Yes , then i am trying to know how will i configure viewBuilder for multiple context should i use folder structure like.
Normally it is like this - without context setup
host
viewBuilders
item
collection.js
itemChanged.js
itemCreated.js
itemDeleted.js
Or from viewbuilder testcase reference
host
item
viewbuilders
itemChanged.js
itemCreated.js
itemDeleted.js
collection.js
Machine
viewbuilders
machineChanged.js
machineCreated.js
machineDeleted.js
collection.js
Or according to context manufacturing
host
manufacturing
item
viewbuilders
itemChanged.js
itemCreated.js
itemDeleted.js
collection.js
Machine
viewbuilders
machineChanged.js
machineCreated.js
machineDeleted.js
collection.js
Viewbuilders are structured by collection (not by context). Each viewBuilder reacts on an event and denormalizes that event in an appropriate collection.
:+1:
also nice to know Viewbuilders are structured by collection - my mistake i assumed by context :>)
Steps that i followed to implement context:
1 : Used configuration like,
context: 'context.name', aggregate: 'aggregate.name'
in
domain.defineCommand ({ , domain.defineEvent({ , eventDenormalizer.defineEvent({
2 : structured directory for context manufacturing and aggregate item
3 : added context.js
according to manufacturing context
Doub't :>) :
{ context : '_general' }
.
so does it needs to be { context : 'manufacturing' }
.
As i have item aggregate inside manufacturing contextObservation :
my mistake sorry .. my doub't got cleared here i blindly copy pasted full file path from domain test case and now it is properly showing { context : 'manufacturing' }
in eventstore.
Now testing multiple aggregates in one context then i'll check why readmodel is not generating with context setup :)
while context is setup,
One aggregate in one context works and in event store it shows {context:'manufacturing'}
But
two aggregates in one context dosen't and in event store it shows {context:'_general'}
How did i checked two aggregates dosen't work ..? initially it was only item aggregate - works nice, but when i added machine aggregate - it dosen't works. its not that machine aggregate is having errors, I INDIVIDUALLY tested both aggregates they work proper.
is there missing any thing ..
Do you have this on github? so I can try?
ahh didn't see your link, sorry
you have not specified de context name in the command message context.name: https://github.com/pawarvijay/cqrs-sample/blob/master/domain/server.js#L89 the command should have a property context: { name: 'item' } now
:)
i specified context name in the command message and tested
this time it neither generated event nor revision.
can you give me write access to your repo?
yes , i have added you as collaborator
retry ;-)
:/ hmm i think some trails of mistake from my side.
i mistakely coded : context: { name: 'item' }
,context: { name: 'machine' }
note : item and machine are not my context
instead of : context: { name: 'manufactoring' }
,context: { name: 'sales' }
note : manufactoring is my context
from : context: { name: 'item' }
,context: { name: 'machine' }
to:aggregate: { name: 'item' }
,aggregate: { name: 'machine' }
when i tested app with this setup it showed
{"context" : "manufactoring"}
for manufactoring context ,
{"context" : "sales"}
for sales context ,
properly in eventstore
but but
when i tested same aggregate in different context they were not working
i am changing : aggregate: { name: 'item' }
,aggregate: { name: 'machine' }
to:context: { name: 'manufactoring' }
,context: { name: 'sales' }
when i tested app with this setup it showed
{"context" : "manufactoring"}
for manufactoring context ,
{"context" : "sales"}
for sales context ,
properly in eventstore
Also
when i tested same aggregate in different context they were also working :+1:
Also i believe commit | little optimization for structureLoader | domain version v2.1.1 is related to this issue
;-)
@adrai i think purpose of question is done understanding / implementing context example :+1: . And in this example readmodel that is not generating .I will first debug it my self and carry out in next issue :)
Read model generating successfully #17
Define the event structure in
denormalizer.defineEvent
need more understanding on below lines
// optional, only makes sense if contexts are defined in the 'domainPath' structure
context: 'context.name',
// optional, only makes sense if aggregates with names are defined in the 'domainPath' structure
aggregate: 'aggregate.name',
Is this configuration about LOGICAL directory structure ? EXAMPLE :This is what i am trying to say