Skip to content

Commit

Permalink
Added FromJSON instance for Id's
Browse files Browse the repository at this point in the history
  • Loading branch information
mpscholten committed Jun 12, 2021
1 parent d794ff8 commit f9fb666
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion IHP/ModelSupport.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import qualified Control.Newtype.Generics as Newtype
import Control.Applicative (Const)
import qualified GHC.Types as Type
import qualified Data.Text as Text
import Data.Aeson (ToJSON (..))
import Data.Aeson (ToJSON (..), FromJSON (..))
import qualified Data.Aeson as Aeson
import qualified Data.Set as Set
import qualified Text.Read as Read
Expand Down Expand Up @@ -696,6 +696,8 @@ fieldWithUpdate name model
instance (ToJSON (PrimaryKey a)) => ToJSON (Id' a) where
toJSON (Id a) = toJSON a

instance (FromJSON (PrimaryKey a)) => FromJSON (Id' a) where
parseJSON value = Id <$> parseJSON value

-- | Thrown by 'fetchOne' when the query result is empty
data RecordNotFoundException
Expand Down

0 comments on commit f9fb666

Please sign in to comment.