Created
October 27, 2012 20:57
-
-
Save aseemk/3966223 to your computer and use it in GitHub Desktop.
Neo4j mutable Cypher, e.g. creating comments (node + relationships + update stats)
This file contains 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
results = @query _, """ | |
START author=node({authorId}), target=node({targetId}) | |
CREATE comment={commentData} | |
CREATE comment -[:#{@REL_AUTHOR} {relAuthorData}]-> author | |
CREATE comment <-[:#{@REL_COMMENT} {relTargetData}]- target | |
SET author.numCommentsBy = COALESCE(author.numCommentsBy?, 0) + 1 | |
SET target.numComments = COALESCE(target.numComments?, 0) + 1 | |
RETURN comment | |
""", | |
authorId: author.id | |
targetId: target.id | |
commentData: @_createNodeData(data) | |
relAuthorData: @_createRelationshipData() | |
relTargetData: @_createRelationshipData() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment