haskell-neo4j-client-0.2.0.0: A Haskell neo4j client

Safe HaskellNone

Database.Neo4j.Cypher

Contents

Description

Module to provide Cypher support. Currently we allow sending queries with parameters, the result is a collection of column headers and JSON data values, the Graph object has the function addCypher that tries to find nodes and relationships in a cypher query result and insert them in a Database.Neo4j.Graph object

 import qualified Database.Neo4j.Cypher as C

 withConnection host port $ do
    ...
    -- Run a cypher query with parameters
    res <- C.cypher "CREATE (n:Person { name : {name} }) RETURN n" M.fromList [("name", C.newparam ("Pep" :: T.Text))]

    -- Get all nodes and relationships that this query returned and insert them in a Graph object
    let graph = G.addCypher (C.fromSuccess res) G.empty

    -- Get the column headers
    let columnHeaders = C.cols $ C.fromSuccess res

    -- Get the rows of JSON values received
    let values = C.vals $ C.fromSuccess res

Synopsis

Types

data Response Source

Type for a Cypher response with tuples containing column name and their values

Constructors

Response 

Fields

cols :: [Text]
 
vals :: [[Value]]
 

Instances

Eq Response 
Show Response 
FromJSON Response

How to create a response object from a cypher JSON response

data ParamValue Source

Value for a cypher parmeter value, might be a literal, a property map or a list of property maps

Instances

Eq ParamValue 
Show ParamValue 
ToJSON ParamValue

Instance toJSON for param values so we can serialize them in queries

type Params = HashMap Text ParamValueSource

We use hashmaps to represent Cypher parameters

newparam :: PropertyValueConstructor a => a -> ParamValueSource

Sending queries

cypher :: Text -> Params -> Neo4j (Either Text Response)Source

Run a cypher query

fromResult :: Response -> Either Text Response -> ResponseSource

Get the result of the response or a default value

fromSuccess :: Either Text Response -> ResponseSource

Get the result of the response or a default value

isSuccess :: Either Text Response -> BoolSource

True if the operation succeeded