Comments (7)
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.
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.
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.
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.
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.
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.
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)
- 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
- 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.