Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Array properties #2

Closed
danielkrizian opened this issue Aug 19, 2014 · 1 comment
Closed

Array properties #2

danielkrizian opened this issue Aug 19, 2014 · 1 comment
Labels

Comments

@danielkrizian
Copy link

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
Copy link
Owner

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants