Created
December 19, 2014 20:56
-
-
Save maxicecilia/a19574672fbc1050e9db to your computer and use it in GitHub Desktop.
Some Neo4j queries
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 a simple node | |
MERGE (actor:test_article { aid:"112"}) | |
ON CREATE SET actor.created = timestamp(), actor.api = "api", actor.type = "test_article" | |
-- Create activities | |
MERGE (actor:test_user { aid:"110"}) | |
ON CREATE SET actor.created = timestamp(), actor.api = "api", actor.type = "test_user" | |
ON MATCH SET actor.updated = timestamp() | |
WITH actor | |
MERGE (object:test_comment { aid:"111"}) | |
ON CREATE SET object.created = timestamp(), object.api = "api", object.type = "test_comment" | |
ON MATCH SET object.updated = timestamp() | |
WITH object, actor | |
MERGE (actor)-[verb:WROTE]->(object) | |
ON CREATE SET verb.created = timestamp() | |
ON CREATE SET verb.target = "112" | |
ON MATCH SET verb.updated = timestamp() | |
RETURN actor, verb, object; | |
-- Select an activity with his target | |
MATCH (u:test_user)-[r:WROTE]->(c:test_comment) | |
OPTIONAL MATCH (p:test_article) | |
where (has (r.target) and p.aid=r.target) | |
RETURN u, r, c, p; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment