Giter Site home page Giter Site logo

Comments (7)

nanov avatar nanov commented on May 29, 2024 2

Having what @adrai said in mind, there are a few patterns you can apply to solve your problem, after you have decided that cqrs/es is suitable for youe user/account management:

  • in your case you can set the aggregate id as the email, and give the command a rule that the aggregate does not exists.

  • you may take a look on this answer that i gave for similar question - as last resort this is a solution.
    In your case

from node-cqrs-domain.

adrai avatar adrai commented on May 29, 2024 1

Hehe... welcome to the cqrs world...
Do not mix domain and eventDenormalizer stuff that way.
To solve this you really need 1 aggregate.
To make this more efficient when having too much events, there are snapshots.

from node-cqrs-domain.

imissyouso avatar imissyouso commented on May 29, 2024

Also the way

If you really want to solve it in the domain, you need only 1 aggregate instance i.e. with a fix aggregate id (i.e. USER_EMAILS)

is not a suitable because for every check we need to load the whole aggregate with full list of emails and then make check directly in code (in cycle?). What if we have > 1k users? We cannot make such complex operation just for simple checking for uniqueness.

Thanks for reply in advance.

from node-cqrs-domain.

imissyouso avatar imissyouso commented on May 29, 2024

Found similar question on stackoverflow
https://stackoverflow.com/questions/31386244/cqrs-event-sourcing-check-username-is-unique-or-not-from-eventstore-while-sendin
conclusion: there is no universal way how to do that. In most cases we have to put up with possible data inconsistency in such types of architectures and do not try to hack CAP theorem.

from node-cqrs-domain.

dmitry-textmagic avatar dmitry-textmagic commented on May 29, 2024

The second approach is quite clear. But in the first one, how should we manage email change? If we set an email as an aggregate id, then change email (and it was aggregate id), it causes that any other entities that have this aggregate id (email, in this case) inside would be linked to non-existent/invalid aggregate.

from node-cqrs-domain.

adrai avatar adrai commented on May 29, 2024

This is why I said, you need 1 aggregate for all email addresses...
Or solve this outside of cqrs.
PS. sorry for not responding with a more complete/longer answer... writing from hospital

from node-cqrs-domain.

imissyouso avatar imissyouso commented on May 29, 2024

This is why I said, you need 1 aggregate for all email addresses...
Or solve this outside of cqrs.
PS. sorry for not responding with a more complete/longer answer... writing from hospital

I wish you a speedy recovery!

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.