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).
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.
@juliobiason both are fine. It's even fine to generate them client-side. Generating them independantly from the database also means you don't have to do a round-trip to get the ID of the entry you just generated
The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!