-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathqueries.js
38 lines (34 loc) · 1.12 KB
/
queries.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var multiline = require('multiline');
exports.upsertOne = multiline(function(){/*
MERGE (n:Person {screen_name: {screenName}})
ON CREATE SET n={userMap}
RETURN n
*/});
/*
* Parameters are:
*
* screenName - string, the handle of the person to attach followers to
* userList - array of objects, people to merge and create relationships
*/
exports.upsertManyAndFollows = multiline(function() {/*
MERGE (followeeNode:Person {screen_name: {screenName}})
FOREACH (follower in {userList} |
MERGE (followerNode:Person {screen_name: follower.screen_name})
ON CREATE SET followerNode=follower
MERGE followerNode-[:FOLLOWS]->followeeNode
)
*/});
/*
* Parameters are:
*
* screenName - string, the handle of the person to attach followers to
* userList - array of objects, people to merge and create relationships
*/
exports.upsertManyAndFriends = multiline(function() {/*
MERGE (targetNode:Person {screen_name: {screenName}})
FOREACH (friend in {userList} |
MERGE (friendNode:Person {screen_name: friend.screen_name})
ON CREATE SET friendNode=friend
MERGE targetNode-[:FOLLOWS]->friendNode
)
*/});