I'm using the replaceUnique
method, which has return type of ReaderT backend m (Maybe (Unique record))
. My database table has two unique fields and if uniqueness is violated, I want to find out which key is conflicting. How can I do that?
This can be achieved with this code:
case unique of
UniqueEmail _ -> -- email is conflicting
UniqueDisplayName _ -> -- displayName is conflicting
where unique
is Unique record
and UniqueEmail _
and UniqueDisplayName _
are uniqueness constraints.