Change the name User to Account
Next I'll need to add / remove fields from the Account type.
This commit is contained in:
parent
718152ec14
commit
d011616564
3 changed files with 12 additions and 12 deletions
12
src/Types.hs
12
src/Types.hs
|
|
@ -16,20 +16,20 @@ import Database.Persist.TH
|
|||
--------------------------------------------------------------------------------
|
||||
|
||||
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
|
||||
User
|
||||
Account
|
||||
name Text
|
||||
age Int
|
||||
UniqueName name
|
||||
deriving Eq Read Show
|
||||
|]
|
||||
|
||||
instance FromJSON User where
|
||||
instance FromJSON Account where
|
||||
parseJSON = withObject "User" $ \ v ->
|
||||
User <$> v .: "name"
|
||||
<*> v .: "age"
|
||||
Account <$> v .: "name"
|
||||
<*> v .: "age"
|
||||
|
||||
instance ToJSON User where
|
||||
toJSON (User name age) =
|
||||
instance ToJSON Account where
|
||||
toJSON (Account name age) =
|
||||
object [ "name" .= name
|
||||
, "age" .= age
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue