File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ module Aws.DynamoDb.Core
7575 , Parser (.. )
7676 , getAttr
7777 , getAttr'
78+ , parseAttr
7879
7980 -- * Common types used by operations
8081 , Conditions (.. )
@@ -1348,6 +1349,19 @@ getAttr' k m = do
13481349 Nothing -> return Nothing
13491350 Just dv -> return $ fromValue dv
13501351
1352+ -- | Combinator for parsing an attribute into a 'FromDynItem'.
1353+ parseAttr
1354+ :: FromDynItem a
1355+ => T. Text
1356+ -- ^ Attribute name
1357+ -> Item
1358+ -- ^ Item from DynamoDb
1359+ -> Parser a
1360+ parseAttr k m =
1361+ case M. lookup k m of
1362+ Nothing -> fail (" Key " <> T. unpack k <> " not found" )
1363+ Just (DMap dv) -> either (fail " ..." ) return $ fromItem dv
1364+ _ -> fail (" Key " <> T. unpack k <> " is not a map!" )
13511365
13521366-------------------------------------------------------------------------------
13531367-- | Parse an 'Item' into target type using the 'FromDynItem'
You can’t perform that action at this time.
0 commit comments