Safe Haskell | None |
---|
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
- data Response = Response {}
- data ParamValue
- type Params = HashMap Text ParamValue
- newparam :: PropertyValueConstructor a => a -> ParamValue
- cypher :: Text -> Params -> Neo4j (Either Text Response)
- fromResult :: Response -> Either Text Response -> Response
- fromSuccess :: Either Text Response -> Response
- isSuccess :: Either Text Response -> Bool
Types
Type for a Cypher response with tuples containing column name and their values
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
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