How do I select a node by property using neography?

106 Views Asked by At

Can I use the neography DSL to do this query?

Neo.execute_query "
  MATCH (user:User{id: #{id}})
  SET user.name = '#{given_name} #{surname}'
  SET user.email = '#{email}'
"
1

There are 1 best solutions below

0
On BEST ANSWER

Neography is not a DSL, but a wrapper around the REST API of Neo4J. As long as your query is a valid Cypher one, you can execute it like that. In you case, the 'id' is not a classic property, so I think you cannot use it like that. You may rewrite your query like this:

START user=node(#{id}) SET user.name = '#{given_name} #{surname}' SET user.email = '#{email}'

You may want to use parameters as well: http://docs.neo4j.org/chunked/milestone/rest-api-cypher.html