-
Notifications
You must be signed in to change notification settings - Fork 0
/
command
133 lines (41 loc) · 2.21 KB
/
command
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//create a new node
create (n:Person {name:"Arafat"}) return n
create (n:Person {name:"Arafat2"}) return n
create (n:Person {name:"Arafat3"}) return n
create (n:Person {name:"Arafat4"}) return n
//create a graph using all nodes of n
match (n:Person) return n
create (n:Movies {name2:"Arafat5"}) return n
create (n:Movies {name2:"Arafat6"}) return n
create (n:Movies {name2:"Arafat7"}) return n
create (n:Movies {name2:"Arafat8"}) return n
match (n:Movies) return n
//making whole graph
match(n) return n
//adding a property to a node
match(n:Person {name:"Arafat"}) set n.age=22
//for updating property
match(n:Person {name:"Arafat"}) set n.age=22
//removing a property
match(n:Person {name:"Arafat"}) remove n.age
//making a relation between graphs
match (a:Person {name:"Arafat"}),(b:Person {name:"ahimas"}) merge (a)-[r:crush]->(b)
match (a:Movies {name:"Sherlock Holmes"}),(b:Movies {names:"X-man"}) merge (a)-[r:uhu]->(b)
match (a:Person {name:"ssush"}),(b:Movies {name:"X-man"}) merge (a)-[r:fav]->(b)
//find a node
match(n:Person) where n.name="Arafat" return n
match(n:Person {name="Arafat"}) return n
//return a property
match(n:Person) where n.name="Arafat" return n.name
match(n:Person) where n.name="Arafat" or n.name="ssush" return n
//search in relationship.
match(a:Person {name:"Arafat"})-[:crush]->(b:Person) return a,b
match(a:Person {name:"Arafat"})-[:crush]->(b:Person) return b
match(a:Person)-[:crush]->(b:Person {name:"Arafat"} ) return a,b //no row, cz directed graph was created
match(a:Person)-[:crush]-(b:Person {name:"Arafat"} ) return a,b //ja asw.e tai e dibe
match(a:Person)<-[:crush]-(b:Person {name:"Arafat"} ) return a,b //dibe
//Deletetion of a node=== if a node is in a relationship , it cant be deleted easily
match(a:Person {name:"Arafat"}) delete a //not deleted
match(a:Person {name:"Arafat"})-[r]-(b) delete r //1stly deletenig the relations == then delete the desired node
match(a:Movies {name:"GodFather"}) delete a //deleted
match (n) optional match (n)-[r]-() delete n,r