neo4j-rstats / neo4r

A Modern and Flexible Neo4J Driver
https://neo4j-rstats.github.io/user-guide/
Other
106 stars 29 forks source link

Passing parameters to queries #48

Open gregleleu opened 5 years ago

gregleleu commented 5 years ago

It's useful to be able to pass data as "parameters" in the queries. (E.g. to load json, see https://neo4j.com/blog/cypher-load-json-from-url/)

I've updated the code in my fork below. Seems to be working so far... if it helps. (Not doing a pull request as I've not tried every potential impact...)

to_json_neo <- function(query, params, include_stats, meta, type) {
  toJSON(
    list(
      statement = query,
      parameters = params,
      includeStats = include_stats,
      meta = meta,
      resultDataContents = list(type)
    ),
    auto_unbox = TRUE
  )
}
ColinFay commented 5 years ago

Hey,

Good idea, thanks for the suggestion :)

As R evaluates parameterq by position, it's a breaking change to move parameters around in a function, so I'd suggest adding this params at the end of call_neo4j here : https://github.com/gregleleu/neo4r/blob/master/R/call_api.R#L41