Created
May 5, 2014 06:34
-
-
Save wmfairuz/11530011 to your computer and use it in GitHub Desktop.
neo4j-cypher-node-crud
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
** CREATE ** | |
// empty node | |
CREATE (n) RETURN n | |
// node with properties | |
CREATE (n {name : 'Fairuz'}) RETURN n | |
// add relationship | |
START a=node(1), b=node(2) | |
CREATE a-[r:FRIEND_OF]->b | |
RETURN r | |
// add relationship with properties | |
START a=node(1), b=node(2) | |
CREATE a-[r:BEST_FRIEND_OF {name : a.name + '<->' + b.name }]->b | |
RETURN r | |
// create index (use web gui / rest) | |
// add node to index (not possible. Use java api) | |
** UPDATE ** | |
START n = node(2) | |
SET n.name = 'Ali' | |
RETURN n | |
** DELETE ** | |
// delete a property | |
START n = node(2) | |
SET n.name = null | |
RETURN n | |
// delete a node | |
START n = node(4) | |
DELETE n | |
// delete node and relationships | |
START n = node(3) | |
MATCH n-[r]-() | |
DELETE n, r | |
** REINDEX ** | |
START n=node(*) WHERE HAS(n.name) SET n.name=n.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment