-
Notifications
You must be signed in to change notification settings - Fork 2
/
ngql.go
210 lines (183 loc) · 6.35 KB
/
ngql.go
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
package nebulaorm
import "github.com/haysons/nebulaorm/clause"
// Raw exec nGQL statements natively
// see more information on the method of the same name in statement.Statement
func (db *DB) Raw(raw string) (tx *DB) {
tx = db.getInstance()
tx.Statement.Raw(raw)
return tx
}
// Go generate go clause
// see more information on the method of the same name in statement.Statement
func (db *DB) Go(step ...int) (tx *DB) {
tx = db.getInstance()
tx.Statement.Go(step...)
return
}
// From generate from clause
// see more information on the method of the same name in statement.Statement
func (db *DB) From(vid interface{}) (tx *DB) {
tx = db.getInstance()
tx.Statement.From(vid)
return
}
// Over generate over clause
// see more information on the method of the same name in statement.Statement
func (db *DB) Over(edgeType ...string) (tx *DB) {
tx = db.getInstance()
tx.Statement.Over(edgeType...)
return
}
// Where generate where clause
// see more information on the method of the same name in statement.Statement
func (db *DB) Where(query string, args ...interface{}) (tx *DB) {
tx = db.getInstance()
tx.Statement.Where(query, args...)
return
}
// Or generate or clause
// see more information on the method of the same name in statement.Statement
func (db *DB) Or(query string, args ...interface{}) (tx *DB) {
tx = db.getInstance()
tx.Statement.Or(query, args...)
return
}
// Not generate not clause
// see more information on the method of the same name in statement.Statement
func (db *DB) Not(query string, args ...interface{}) (tx *DB) {
tx = db.getInstance()
tx.Statement.Not(query, args...)
return
}
// Xor generate xor clause
// see more information on the method of the same name in statement.Statement
func (db *DB) Xor(query string, args ...interface{}) (tx *DB) {
tx = db.getInstance()
tx.Statement.Xor(query, args...)
return
}
// Sample generate sample clause
// see more information on the method of the same name in statement.Statement
func (db *DB) Sample(sampleList ...int) (tx *DB) {
tx = db.getInstance()
tx.Statement.Sample(sampleList...)
return
}
// Fetch generate fetch clause
// see more information on the method of the same name in statement.Statement
func (db *DB) Fetch(name string, vid interface{}) (tx *DB) {
tx = db.getInstance()
tx.Statement.Fetch(name, vid)
return
}
// FetchMulti generate fetch clause,multiple tag or edge types
// see more information on the method of the same name in statement.Statement
func (db *DB) FetchMulti(names []string, vid interface{}) (tx *DB) {
tx = db.getInstance()
tx.Statement.FetchMulti(names, vid)
return
}
// Lookup generate lookup clause
// see more information on the method of the same name in statement.Statement
func (db *DB) Lookup(name string) (tx *DB) {
tx = db.getInstance()
tx.Statement.Lookup(name)
return
}
// GroupBy generate group by clause
// see more information on the method of the same name in statement.Statement
func (db *DB) GroupBy(expr string) (tx *DB) {
tx = db.getInstance()
tx.Statement.GroupBy(expr)
return
}
// Yield generate yield clause
// see more information on the method of the same name in statement.Statement
func (db *DB) Yield(expr string, distinct ...bool) (tx *DB) {
tx = db.getInstance()
tx.Statement.Yield(expr, distinct...)
return
}
// OrderBy generate order by clause
// see more information on the method of the same name in statement.Statement
func (db *DB) OrderBy(expr string) (tx *DB) {
tx = db.getInstance()
tx.Statement.OrderBy(expr)
return
}
// Limit generate limit clause
// see more information on the method of the same name in statement.Statement
func (db *DB) Limit(limit int, offset ...int) (tx *DB) {
tx = db.getInstance()
tx.Statement.Limit(limit, offset...)
return
}
// InsertVertex generate insert vertex clause
// see more information on the method of the same name in statement.Statement
func (db *DB) InsertVertex(vertexes interface{}, ifNotExist ...bool) (tx *DB) {
tx = db.getInstance()
tx.Statement.InsertVertex(vertexes, ifNotExist...)
return
}
// UpdateVertex generate update vertex clause
// see more information on the method of the same name in statement.Statement
func (db *DB) UpdateVertex(vid interface{}, propsUpdate interface{}, opts ...clause.Option) (tx *DB) {
tx = db.getInstance()
tx.Statement.UpdateVertex(vid, propsUpdate, opts...)
return
}
// UpsertVertex generate upsert vertex clause
// see more information on the method of the same name in statement.Statement
func (db *DB) UpsertVertex(vid interface{}, propsUpdate interface{}, opts ...clause.Option) (tx *DB) {
tx = db.getInstance()
tx.Statement.UpsertVertex(vid, propsUpdate, opts...)
return
}
// DeleteVertex generate delete vertex clause
// see more information on the method of the same name in statement.Statement
func (db *DB) DeleteVertex(vid interface{}, withEdge ...bool) (tx *DB) {
tx = db.getInstance()
tx.Statement.DeleteVertex(vid, withEdge...)
return
}
// InsertEdge generate insert edge clause
// see more information on the method of the same name in statement.Statement
func (db *DB) InsertEdge(edges interface{}, ifNotExist ...bool) (tx *DB) {
tx = db.getInstance()
tx.Statement.InsertEdge(edges, ifNotExist...)
return
}
// UpdateEdge generate update edge clause
// see more information on the method of the same name in statement.Statement
func (db *DB) UpdateEdge(edge interface{}, propsUpdate interface{}, opts ...clause.Option) (tx *DB) {
tx = db.getInstance()
tx.Statement.UpdateEdge(edge, propsUpdate, opts...)
return
}
// UpsertEdge generate upsert edge clause
// see more information on the method of the same name in statement.Statement
func (db *DB) UpsertEdge(edge interface{}, propsUpdate interface{}, opts ...clause.Option) (tx *DB) {
tx = db.getInstance()
tx.Statement.UpsertEdge(edge, propsUpdate, opts...)
return
}
// DeleteEdge generate delete edge clause
// see more information on the method of the same name in statement.Statement
func (db *DB) DeleteEdge(edgeTypeName string, edge interface{}) (tx *DB) {
tx = db.getInstance()
tx.Statement.DeleteEdge(edgeTypeName, edge)
return
}
// When generate when edge clause
// see more information on the method of the same name in statement.Statement
func (db *DB) When(query string, args ...interface{}) (tx *DB) {
tx = db.getInstance()
tx.Statement.When(query, args...)
return
}
// Pipe add a pipe character in current nGQL
func (db *DB) Pipe() (tx *DB) {
tx = db.getInstance()
tx.Statement.Pipe()
return
}