Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggregate/Entity ids handling. #316

Closed
stefanondisponibile opened this issue Dec 24, 2020 · 2 comments
Closed

Aggregate/Entity ids handling. #316

stefanondisponibile opened this issue Dec 24, 2020 · 2 comments

Comments

@stefanondisponibile
Copy link

stefanondisponibile commented Dec 24, 2020

Hello!
In Chapter 9 we need a Temporary Ugly Hack: The Message Bus Has to Return Results.
That's fine, since that's "solved" by CQRS in Chapter 12. However, what concerns me is: where should ids be handled?. Generically at a "system" level or at "Domain Model" level?

In one of the examples, more or less, this is what is done:

order_id = random_order_id()
api_client.post_to_allocate(order_id, sku, qty=3)

And this is kinda fine, since we would probably be getting the order_id from a view with CQRS. But how about creation of new objects? Where should the "id logic" be put?

# Creating new "Thing"
new_thing_id = 123  # the logic is either here or "lost", unless we return from the message bus 🤔
api_client.post_to_create_new_thing(new_thing_id)

This is somehow related to #299 too.

@hjwp
Copy link
Contributor

hjwp commented Dec 29, 2020

one solution is to choose the unique ids yourself, rather than letting the database do it for you. there's an example in one of @bobthemighty's original blog posts: https://www.cosmicpython.com/blog/2017-09-13-commands-and-queries-handlers-and-views.html

@dbaber
Copy link

dbaber commented May 4, 2024

I think I ran into something similar and came to the conclusion that I'd rather just generate a seeded uuidv5 and store that as the PK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants