Fix comments import

@appinteractive
This commit is contained in:
Robert Schäfer 2019-02-05 20:02:59 +01:00
parent 0705ab1bf5
commit 9656bd4eb7

View File

@ -1,12 +1,14 @@
CALL apoc.load.json('file:/mongo-export/comments.json') YIELD value as comment
MERGE (c:Comment {id: comment._id["$oid"]})
CALL apoc.load.json('file:/mongo-export/comments.json') YIELD value as json
MERGE (comment:Comment {id: json._id["$oid"]})
ON CREATE SET
c.content = comment.content,
c.contentExcerpt = comment.contentExcerpt,
c.deleted = comment.deleted,
c.disabled = false
WITH comment
MATCH (p:Post {id: comment.contributionId}), (u:User {id: comment.userId})
MERGE (c)-[:COMMENTS]->(p)
MERGE (u)-[:WROTE]->(c)
comment.content = json.content,
comment.contentExcerpt = json.contentExcerpt,
comment.deleted = json.deleted,
comment.disabled = false
WITH comment, json, json.contributionId as postId
MATCH (post:Post {id: postId})
WITH comment, post, json.userId as userId
MATCH (author:User {id: userId})
MERGE (comment)-[:COMMENTS]->(post)
MERGE (author)-[:WROTE]->(comment)
;