haskell-neo4j-client 0.3.2.0 → 0.3.2.1
raw patch · 4 files changed
+20/−14 lines, 4 files
Files
- haskell-neo4j-client.cabal +1/−1
- src/Database/Neo4j/Traversal.hs +13/−10
- src/Database/Neo4j/Types.hs +5/−2
- src/Database/Neo4j/Version.hs +1/−1
haskell-neo4j-client.cabal view
@@ -1,5 +1,5 @@ name: haskell-neo4j-client-version: 0.3.2.0+version: 0.3.2.1 synopsis: A Haskell neo4j client description: Library to interact with Neo4j databases.
src/Database/Neo4j/Traversal.hs view
@@ -53,7 +53,10 @@ data ReturnFilter = ReturnAll | ReturnAllButStartNode deriving (Eq, Show) type RelFilter = (RelationshipType, Direction)+newtype RelFilterT = RelFilterT {runRelFilter :: RelFilter} -- Useful to make a ToJSON instance of the type alias +newtype MaybeUniqueness = MaybeUniqueness {runMaybeUniqueness :: Maybe Uniqueness} -- Useful for ToJSON of type alias+ -- | Type containing all info describing a traversal request data TraversalDesc = TraversalDesc { travOrder :: TraversalOrder,@@ -66,8 +69,8 @@ traversalReqBody :: TraversalDesc -> L.ByteString traversalReqBody (TraversalDesc ord relfilt uniq depth nodefilt) = J.encode $ J.object [ "order" .= J.toJSON ord,- "relationships" .= relfilt,- "uniqueness" .= uniq,+ "relationships" .= map RelFilterT relfilt,+ "uniqueness" .= MaybeUniqueness uniq, depthField depth, "return_filter" .= returnField nodefilt ]@@ -88,19 +91,19 @@ toJSON ReturnAllButStartNode = J.String "all_but_start_node" -- | How to codify RelFilter values into JSON-instance J.ToJSON RelFilter where- toJSON (rType, dir) = J.object ["direction" .= dirToJson dir, "type" .= J.toJSON rType]+instance J.ToJSON RelFilterT where+ toJSON (RelFilterT (rType, dir)) = J.object ["direction" .= dirToJson dir, "type" .= J.toJSON rType] where dirToJson Outgoing = J.String "out" dirToJson Incoming = J.String "in" dirToJson Any = J.String "all" -- | How to codify uniqueness values into JSON-instance J.ToJSON (Maybe Uniqueness) where- toJSON Nothing = J.String "none"- toJSON (Just NodeGlobal) = J.String "node_global"- toJSON (Just RelationshipGlobal) = J.String "relationship_global"- toJSON (Just NodePathUnique) = J.String "node_path"- toJSON (Just RelationshipPath) = J.String "relationship_path"+instance J.ToJSON MaybeUniqueness where+ toJSON (MaybeUniqueness Nothing) = J.String "none"+ toJSON (MaybeUniqueness (Just NodeGlobal)) = J.String "node_global"+ toJSON (MaybeUniqueness (Just RelationshipGlobal)) = J.String "relationship_global"+ toJSON (MaybeUniqueness (Just NodePathUnique)) = J.String "node_path"+ toJSON (MaybeUniqueness (Just RelationshipPath)) = J.String "relationship_path" instance Default TraversalDesc where def = TraversalDesc {travOrder = BreadthFirst, travRelFilter = [], travUniqueness = Nothing,
src/Database/Neo4j/Types.hs view
@@ -38,6 +38,9 @@ import qualified Network.HTTP.Conduit as HC import qualified Network.HTTP.Types as HT ++newtype Neo4jVersion = Neo4jVersion {runVersion :: Version}+ (<>) :: (Monoid a) => a -> a -> a (<>) = mappend @@ -377,7 +380,7 @@ -- f $ liftM StNeo4j . runInBase . (\(Neo4j r) -> r conn) -- restoreM (StNeo4j x) = Neo4j $ const $ restoreM x -instance J.FromJSON Version where- parseJSON (J.Object v) = v .: "neo4j_version" >>= (\s -> return $ fst . last $ readP_to_S parseVersion s)+instance J.FromJSON Neo4jVersion where+ parseJSON (J.Object v) = liftM (Neo4jVersion . fst . last . readP_to_S parseVersion) (v .: "neo4j_version") parseJSON _ = mzero
src/Database/Neo4j/Version.hs view
@@ -7,5 +7,5 @@ import Database.Neo4j.Http import Database.Neo4j.Types -getDatabaseVersion :: Neo4j Version+getDatabaseVersion :: Neo4j Neo4jVersion getDatabaseVersion = Neo4j $ \conn -> httpRetrieveSure conn "/db/data"