-
Notifications
You must be signed in to change notification settings - Fork 0
/
queries
122 lines (100 loc) · 1.77 KB
/
queries
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
// SLIDE: 35.1 -- First query to show the browser
// Show off basic use and eq()
{
users(func: eq(type, "user")) {
name
skills : skill {
name
}
}
}
// SLIDE: 35.2 -- Second query to show off the browser
// Show off anyofterms()
{
tickets(func: anyofterms(type, "ticket")) {
name
desc
tags : tag {
name
}
}
}
// SLIDE: 35.3 -- Third query to show off the browser
// Sow off reverse traversal
{
skills(func: eq(type, "skill")) {
name
has_skill : ~skill {
name
}
has_tag : ~tag {
name
}
}
}
// 39.1 -- Find the ticket you want
{
ticket(func: allofterms(name, "first")) {
name
desc
tags : tag {
name
}
}
}
// 39.2 -- find all the users that match the criteria
{
ticket(func: allofterms(name, "first")) {
name
desc
tags : tag {
name
skills : ~skill {
name
}
}
}
}
// 39.3 -- find just the users
{
var(func: allofterms(name, "first")) {
a as math(1)
tag {
~skill {
userScore as math(a)
}
}
}
users(func: uid(userScore), orderdesc: val(userScore), first: 2) {
_uid_
name
score : val(userScore)
}
}
// 42.1 New Data
// Show crerating new Data, and adding items that are not in the schema
mutation {
set {
_:daniel <name> "daniel" .
_:daniel <type> "user" .
}
}
// 42.2 -- Show the users that was created
{
users(func: eq(type, "user")) {
name
skills : skill {
name
}
}
}
// 42.3 -- Add More data
{
skills as var (func: anyofterms(name, "go linux javascript"))
user as var(func: eq(name, "daniel"))
}
mutation {
set {
uid(user) <skill> uid(skills) .
}
}