Import follows

This commit is contained in:
Robert Schäfer 2019-01-21 23:38:48 +01:00
parent ce7ce40272
commit 932a593cfa
3 changed files with 5 additions and 11 deletions

4
neo4j/import/follows.cql Normal file
View File

@ -0,0 +1,4 @@
CALL apoc.load.json('file:/mongo-export/follows.json') YIELD value as follow
MATCH (u1:User {id: follow.userId}), (u2:User {id: follow.foreignId})
MERGE (u1)-[:FOLLOWS]->(u2)
;

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
SCRIPT_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
echo "MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r;" | cypher-shell
for collection in "badges" "categories" "users" "contributions" "comments"
for collection in "badges" "categories" "users" "follows" "contributions" "comments"
do
echo "Import ${collection}..." && cypher-shell < $SCRIPT_DIRECTORY/$collection.cql
done

View File

@ -1,14 +1,4 @@
CALL apoc.load.json('file:/mongo-export/badges.json') YIELD value as badge
MERGE(b:Badge {id: badge._id["$oid"]})
ON CREATE SET b.key = badge.key,
b.type = badge.type,
b.icon = badge.image.path,
b.status = badge.status
CALL apoc.load.json('file:/mongo-export/follows.json') YIELD value as follow
MATCH (u1:User {id: follow.userId}),
(u2:User {id: follow.foreignId})
MERGE (u1)-[:FOLLOWS]->(u2)
CALL apoc.load.json('file:/mongo-export/shouts.json') YIELD value as shout
MATCH (u:User {id: shout.userId}),