-
Notifications
You must be signed in to change notification settings - Fork 273
Neo4j::Cypher With
The ability to chain queries together allows for powerful constructs. In Cypher, the WITH clause is used to pipe the result from one query to the next.
WITH
is also used to separate reading from updating of the graph. Every sub-query of a query must be either read-only or write-only.
Example:
node(1) <=> node(:other_person).ret.with(count) { |_, foaf| foaf > 1 }) >> node
Notice that the first argument for the with is the node(:other_person)
which is not used (the _
parameter).
The foaf
parmeter in the ruby block foaf > 1
is the count value.
Same as
START v2=node(1) MATCH (v2)--(other_person)-->(v3) WITH other_person,count(*) as v1 WHERE v1 > 1 RETURN other_person
Example:
node.new(:name => 'Andreas', :age => 42)
Same as CREATE (v1 {name : 'Andreas', age : 42}) RETURN v1
Delete a node:
node(4).del
START v1=node(4) DELETE v1
Delete a relationship
node(3) > rel('r').del > node.del
Same as START v1=node(3) MATCH (v1)-[r]->(v2) DELETE r,v2
Example:
node(1).create_path { |n| n > rel(:friends) > node(2) }
Same as START v1=node(1),v2=node(2) WITH v1 CREATE (v1)-[:
friends]->(v2)
See the RSpecs for more examples see here
WARNING: Much of the information in this wiki is out of date. We are in the process of moving things to readthedocs
- Project Introduction
- Neo4j::ActiveNode
- Neo4j::ActiveRel
- Search and Scope
- Validation, Uniqueness, and Case Sensitivity
- Indexing VS Legacy Indexing
- Optimized Methods
- Inheritance
- Core: Nodes & Rels
- Introduction
- Persistence
- Find : Lucene
- Relationships
- Third Party Gems & extensions
- Scaffolding & Generators
- HA Cluster