| Safe Haskell | Safe-Inferred | 
|---|---|
| Language | Haskell2010 | 
Database.Bolt.Extras.Template
Synopsis
- makeNodeLike :: Name -> Q [Dec]
- makeNodeLikeWith :: Name -> (String -> String) -> Q [Dec]
- makeURelationLike :: Name -> Q [Dec]
- makeURelationLikeWith :: Name -> (String -> String) -> Q [Dec]
Documentation
makeNodeLike :: Name -> Q [Dec] Source #
Make an instance of NodeLike class.
 Only data types with one constructor are currently supported.
 Each field is transformed into Text key and its value is transformed into a Value.
 For example, we have a structure and define an instance:
>>>:{data Foo = Bar { baz :: Double , quux :: Text , quuz :: Maybe Int } deriving (Show) makeNodeLike ''Foo :}
Then you may create example and convert it to and from Node:
>>>let foo = Bar 42.0 "Loren ipsum" (Just 7)>>>toNode fooNode {nodeIdentity = -1, labels = ["Foo"], nodeProps = fromList [("baz",F 42.0),("quux",T "Loren ipsum"),("quuz",I 7)]}>>>fromNode . toNode $ foo :: FooBar {baz = 42.0, quux = "Loren ipsum", quuz = Just 7}
Maybe fields are handled correctly:
>>>let bar = Bar 42.0 "Hello world" Nothing>>>toNode barNode {nodeIdentity = -1, labels = ["Foo"], nodeProps = fromList [("baz",F 42.0),("quux",T "Hello world"),("quuz",N ())]}>>>:{let barNode = Node { nodeIdentity = -1 , labels = ["Foo"] , nodeProps = fromList [("baz", F 42.0), ("quux", T "Hello world")] -- No "quuz" here } :}
>>>fromNode barNode :: FooBar {baz = 42.0, quux = "Hello world", quuz = Nothing}
makeNodeLikeWith :: Name -> (String -> String) -> Q [Dec] Source #
The same as makeNodeLike, but applies a function to all field names before storing them
 in Neo4j, like aeson does.
This can be used with fieldLabelModifier from Options in aeson:
makeNodeLikeWith ''Foo $ fieldLabelModifier $ aesonPrefix camelCase
makeURelationLike :: Name -> Q [Dec] Source #
Make an instance of URelationLike class.
 Transformations are the same as in NodeLike instance declaration with the only one difference:
 URelationship holds only one label (or type), but Node holds list of labels.
makeURelationLikeWith :: Name -> (String -> String) -> Q [Dec] Source #
As makeNodeLikeWith.