Array properties
danielkrizian opened this issue · 1 comments
danielkrizian commented
Hello Nicole,
is it possible to create nodes or relationships with array properties?
library(RJSONIO)
n1 = createNode(graph, name="Node1")
n2 = createNode(graph, name="Node2")
createRel(n1, type="HOLDS", n2, arrayproperty=RJSONIO::toJSON(c(1, 3, 8)))
This query returned NA
:
cypher(graph, "MATCH (a)-[r:HOLDS]->(b) RETURN r.arrayproperty[2]")
nicolewhite commented
Hi Daniel,
Yes, but you don't need to convert to JSON. Just pass the R vector itself. I wrote RNeo4j for the convenience of using R objects.
> library(RNeo4j)
> graph = startGraph("http://localhost:7474/db/data/")
> clear(graph)
You are about to delete all nodes, relationships, indexes, and constraints from the graph database. Are you sure? Y/N
1: Y
> n1 = createNode(graph, name = "Node1")
> n2 = createNode(graph, name = "Node2")
> n3 = createNode(graph, name = "Node3")
>
> r1 = createRel(n1, type = "HOLDS", n2, arrayProperty = c(1,2,3))
> r2 = createRel(n2, type = "HOLDS", n3, arrayProperty = c(4,5,6))
>
> r1$arrayProperty
[1] 1 2 3
> r2$arrayProperty
[1] 4 5 6
> cypher(graph, "MATCH (a)-[r:HOLDS]->(b) RETURN r.arrayProperty[2]")
r.arrayProperty[2]
1 3
2 6
In the future, please use StackOverflow for questions like this.
Nicole