DB
Size: a a a
DB
JS
DB
data User = User { name :: String, email :: String }
searchOld :: (WithID a, WithEntity entity a, WithEntity entity b, WithVersion entity b, WithID b) => a -> IO (Maybe b)
searchOld = ...
saveEntity :: (WithID a, WithEntity a) => a -> IO ()
saveEntity new = do
old <- searchOld entity
if getEntity <$> old == Just (getEntity new)
then save $ withVersion 1 new
else save $ withVersion (fromJust (getVersion <$> old) + 1) new
save
:: (WithID a, WithEntity entity a, WithVersion a) => IO ()
save = ...AA
DB
data User = User { name :: String, email :: String }
searchOld :: (WithID a, WithEntity entity a, WithEntity entity b, WithVersion entity b, WithID b) => a -> IO (Maybe b)
searchOld = ...
saveEntity :: (WithID a, WithEntity a) => a -> IO ()
saveEntity new = do
old <- searchOld entity
if getEntity <$> old == Just (getEntity new)
then save $ withVersion 1 new
else save $ withVersion (fromJust (getVersion <$> old) + 1) new
save
:: (WithID a, WithEntity entity a, WithVersion a) => IO ()
save = ...DB
data User = User { name :: String, email :: String }
searchOld :: (WithID a, WithEntity entity a, WithEntity entity b, WithVersion entity b, WithID b) => a -> IO (Maybe b)
searchOld = ...
saveEntity :: (WithID a, WithEntity a) => a -> IO ()
saveEntity new = do
old <- searchOld entity
if getEntity <$> old == Just (getEntity new)
then save $ withVersion 1 new
else save $ withVersion (fromJust (getVersion <$> old) + 1) new
save
:: (WithID a, WithEntity entity a, WithVersion a) => IO ()
save = ...DB
DB
DB
DB
к
DB