thenativeweb / cqrs-sample

CQRS, EventSourcing, (DDDD) Sample in node.js
148 stars 50 forks source link

need more understanding on - context: 'context.name',aggregate: 'aggregate.name' - in configuration #16

Closed pawarvijay closed 8 years ago

pawarvijay commented 8 years ago

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

cqrs-example
    domain
        lib
           sales (does this stand for CONTEXT .. ?)
                salesinvocie(does this stand for AGGREGATES .. ?)
                    createsalesinvoice.js
                    deletesalesinvoice.js
                salesorder
                    createsalesorder.js
                    deletesalesorder.js
                salesreceipt
                    createsalesreceipt.js
                    deletesalesreceipt.js
            purchase(does this stand for CONTEXT)
                purchaseorder(does this stand for AGGREGATES)
                    createpurchaseorder.js
                    deletepurchaseorder.js
                purchasereqisition
                    createpurchasereqisition.js
                    deletepurchasereqisition.js
adrai commented 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

pawarvijay commented 8 years ago

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
adrai commented 8 years ago

Viewbuilders are structured by collection (not by context). Each viewBuilder reacts on an event and denormalizes that event in an appropriate collection.

pawarvijay commented 8 years ago

:+1:

Doub't :>) :

Observation :

pawarvijay commented 8 years ago

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 :)

pawarvijay commented 8 years ago

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 ..

adrai commented 8 years ago

Do you have this on github? so I can try?

adrai commented 8 years ago

ahh didn't see your link, sorry

adrai commented 8 years ago

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

pawarvijay commented 8 years ago

:)

i specified context name in the command message and tested

this time it neither generated event nor revision.

adrai commented 8 years ago

can you give me write access to your repo?

pawarvijay commented 8 years ago

yes , i have added you as collaborator

adrai commented 8 years ago

retry ;-)

pawarvijay commented 8 years ago

:/ hmm i think some trails of mistake from my side.

1 : when i came to know command should have a property context: { name: 'item' }

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

2 : @adrai then you changed lines in configuration

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

3 : rectified mistake

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:

pawarvijay commented 8 years ago

Also i believe commit | little optimization for structureLoader | domain version v2.1.1 is related to this issue

adrai commented 8 years ago

;-)

pawarvijay commented 8 years ago

@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 :)

pawarvijay commented 8 years ago

Read model generating successfully #17

Fully working example with context setup :+1: