Learn R Programming

RNeo4j (version 1.6.4)

appendCypher: Transactions

Description

Transactions

Usage

appendCypher(transaction, query, ...)
commit(transaction)
newTransaction(graph)

Arguments

transaction
A transaction object.
query
A character string.
...
A named list. Optional parameters to pass to the query in the form key = value, if applicable.
graph
A graph object.

Value

newTransaction returns a transaction object. Both appendCypher and commit return NULL.

Examples

Run this code
## Not run: 
# graph = startGraph("http://localhost:7474/db/data/")
# clear(graph)
# 
# data = data.frame(Origin = c("SFO", "AUS", "MCI"),
#                   FlightNum = c(1, 2, 3),
#                  Destination = c("PDX", "MCI", "LGA"))
# 
# 
# query = "
# MERGE (origin:Airport {name:{origin_name}})
# MERGE (destination:Airport {name:{dest_name}})
# CREATE (origin)<-[:ORIGIN]-(:Flight {number:{flight_num}})-[:DESTINATION]->(destination)
# "
# 
# t = newTransaction(graph)
# 
# for (i in 1:nrow(data)) {
#   origin_name = data[i, ]$Origin
#   dest_name = data[i, ]$Dest
#   flight_num = data[i, ]$FlightNum
# 
#   appendCypher(t,
#                query,
#                origin_name = origin_name,
#                dest_name = dest_name,
#                flight_num = flight_num)
# }
# 
# commit(t)
# 
# cypher(graph, "MATCH (o:Airport)<-[:ORIGIN]-(f:Flight)-[:DESTINATION]->(d:Airport)
#        RETURN o.name, f.number, d.name")
# ## End(Not run)

Run the code above in your browser using DataLab