Search code examples
neo4jneography

How do I select a node by property using neography?


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}'
"

Solution

  • 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