You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
--|Instances to simplify (de-)serializing JSONB from/to DB.newtypePGJSONa=PGJSONaderiving (Eq, Show)
instance (FromJSONa, Typeablea) =>FromField (PGJSONa) where
fromField a b =PGJSON<$> fromJSONField a b
instance (ToJSONa) =>ToField (PGJSONa) where
toField (PGJSON a) = toJSONField a
Then one can simply use them ad hoc:
do
[Only (PGJSON xs)] <- query_ c "select jsonb_build_object('key', 'value')"
assert (xs ==Map.fromList [("key", "value")])
… and similarly, without manually defining To-/FromField instances for all used types.
The text was updated successfully, but these errors were encountered:
Wouldn’t that be useful to have in core?
Then one can simply use them ad hoc:
… and similarly, without manually defining To-/FromField instances for all used types.
The text was updated successfully, but these errors were encountered: