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


@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

@juliobiason Also, using instead of UUIDs may have some advantages depending on how you use/generate your IDs

Sign in to participate in the conversation

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