Giter Site home page Giter Site logo

Comments (16)

adrai avatar adrai commented on May 23, 2024

business rules only applies on 1 aggregate (so you may need a personS aggregate)

from node-cqrs-domain.

gstrit avatar gstrit commented on May 23, 2024

I have to have a person and a persons aggregate ? I'm not sure to understand how it should work

from node-cqrs-domain.

adrai avatar adrai commented on May 23, 2024

no, just a persons aggregate

from node-cqrs-domain.

gstrit avatar gstrit commented on May 23, 2024

OK but can I apply a command createOnePerson to the persons aggregate ?
Thank you for your answers

from node-cqrs-domain.

adrai avatar adrai commented on May 23, 2024

Yes, an aggregate is not an object. it's a container for intensions.

from node-cqrs-domain.

gstrit avatar gstrit commented on May 23, 2024

Ok I understand now how it should work but it doesn't work...

module.exports = require('cqrs-domain').definePreCondition({
    name: 'createPlayer',
    version: 0,
    description: 'unique email address'
}, function (data, agg) {
    var found = _.find(agg.get('players'), function (player) {
      return player.firstname === data.firstname;
    });
    if (found) {
      throw new Error('email already used');
    }
});

agg.get('players') is always empty.

from node-cqrs-domain.

adrai avatar adrai commented on May 23, 2024

how does your defineEvent file for playerCreated looks like?

from node-cqrs-domain.

gstrit avatar gstrit commented on May 23, 2024
module.exports = require('cqrs-domain').defineEvent({
  name: 'playerCreated'
},
function (data, aggregate) {
    aggregate.get('players').push(data);
});

from node-cqrs-domain.

adrai avatar adrai commented on May 23, 2024

is that function called?

from node-cqrs-domain.

gstrit avatar gstrit commented on May 23, 2024

yes it is

from node-cqrs-domain.

adrai avatar adrai commented on May 23, 2024

do you have this project hosted on github? can i look at it?

from node-cqrs-domain.

gstrit avatar gstrit commented on May 23, 2024

https://github.com/gstrit/Test

from node-cqrs-domain.

adrai avatar adrai commented on May 23, 2024

You have to send all createPlayer commands with the same aggregateId

from node-cqrs-domain.

gstrit avatar gstrit commented on May 23, 2024

In my domain, a player is an aggregate root not the collection. If I understand how it works, when a client send a command to update a player, he has to fill the id of the collection as the aggregateId and not the id of the player, right ?

from node-cqrs-domain.

adrai avatar adrai commented on May 23, 2024

no...
to play a bit, just extend your commands with (cmd.payload.id = 'same aggregate Id for all commands';)

the id of your collection player should be passed in the payload like (cmd.payload.playerId = vm.id;)

from node-cqrs-domain.

gstrit avatar gstrit commented on May 23, 2024

Ok thanks

from node-cqrs-domain.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.