haskell-webapps
haskell-webapps copied to clipboard
Discussion: Should domain API take primary key as an argument or the entire record?
should functions like activateTenant
or editProduct
take a TenantID
or ProductID
as input OR Tenant
or Product
Tenant vs TenantID, Requiring a Tenant seems to indicate a select before an update. the Tenant record needs to be populated, then modified based on the query params, then finally sent back across the domain API for an update. You can say semantics indicate the Tenant record is just the differences between what's in the db and the current object, so just update the populated fields. That approach seems confusing for insert though. I like ID, but i'd like to see a slick alternative.
The semantics of those are quite different. A Tenant
is a pure Haskell value, while a TenantId
is a reference to a mutable resource. This distinction makes which to use when quite clear. If you are only performing pure transformations to a value, then Tenant
should be used. Otherwise you need TenantId