Safe Haskell | None |
---|---|
Language | Haskell98 |
IMPORTANT! MODULE DEPRECATED, better use the code in this same library that uses the Neo4j transactional endpoint in Database.Neo4j.Transactional.Cypher 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
Eq ParamValue | |
Show ParamValue | |
ToJSON ParamValue | Instance toJSON for param values so we can serialize them in queries |
type Params = HashMap Text ParamValue Source
We use hashmaps to represent Cypher parameters
newparam :: PropertyValueConstructor a => a -> ParamValue Source
Sending queries
cypher :: Text -> Params -> Neo4j (Either Text Response) Source
Deprecated: Use Database.Neo4j.Transactional.Cypher instead
Run a cypher query
fromResult :: Response -> Either Text Response -> Response Source
Deprecated: Use Database.Neo4j.Transactional.Cypher instead
Get the result of the response or a default value