Question: On an hexagonal architecture, the record ids should be generated in the service or repository layers?

Context: For my next toy project, I'll use UUID as record primary key. Right now I'm wondering if I should generate said UUIDs in the service layer (before it goes to the database) or in the repository layer (straight on top of the database).

Show thread

For one, it seems using UUIDs as primary keys (and identifiers, that is) is kinda a business rule, so it should go in the service layer.

On the other hand, because this is highly tied to the database, it seems it should go to the repository layer, even if no logic besides "how to store this" should be there.

... and, on top of everything, even if I'm talking about hexagonal architecture and layers, which are used in OO design, I don't plan on use an OO language.

Show thread
Sign in to participate in the conversation
Functional Café

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!