Search code snippets, questions, articles... Chrome Extension

neo4j code snippets

Delete node relationship only Cypher query neo4j
MATCH (n {companyname: 'Devsheet'})-[r:KNOWS]->()
DELETE r
Delete a node using id Cypher query
MATCH (n:Person) 
WHERE ID(n)=10
DETACH DELETE n
Delete nodes using Cypher query neo4j
MATCH (n:Movie {name: 'Matrix'})
DELETE n
Sort nodes by id ascending and descending order neo4j Cypher query
//Sort in ascending order
MATCH (n)
RETURN n.fullname, n.email
ORDER BY id(n)

//Sort in descending order
MATCH (n)
RETURN n.fullname, n.email
ORDER BY id(n) DESC
Sort nodes in descending order Cypher query neo4j
MATCH (n)
RETURN n.firstname, n.lastname, n.age
ORDER BY n.age DESC
Return 10 rows using LIMIT Cypher query neo4j
MATCH (n)
RETURN n
LIMIT 10
Create one or multiple nodes Cypher query neo4j
// Create single node
CREATE (n)

// Create more than one node
CREATE (n), (m)
Get nodes using multiple ids Cypher query neo4j
MATCH (n)
WHERE ID(n) IN [0, 1, 7, 8, 10]
RETURN n
Get the type of relationship variables of a node Cypher query neo4j
MATCH (:Person {name: 'J.T. Walsh'})-[r]->(movie)
RETURN type(r)
Get all related nodes of a node using Cypher query neo4j
MATCH (Person {name: 'Lana Wachowski'})--(movie)
RETURN movie
Get node using id Cypher query neo4j
MATCH (a)
WHERE ID(a) = 9 // Pass your node id in place of 9
RETURN a