arangorb 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ArangoRB.gemspec +18 -18
- data/Gemfile +8 -7
- data/LICENSE +21 -21
- data/README.md +906 -867
- data/lib/ArangoRB_AQL.rb +181 -160
- data/lib/ArangoRB_Cache.rb +174 -174
- data/lib/ArangoRB_Col.rb +526 -499
- data/lib/ArangoRB_DB.rb +363 -339
- data/lib/ArangoRB_Doc.rb +319 -298
- data/lib/ArangoRB_Edg.rb +184 -169
- data/lib/ArangoRB_Gra.rb +201 -180
- data/lib/ArangoRB_Index.rb +135 -115
- data/lib/ArangoRB_Replication.rb +261 -0
- data/lib/ArangoRB_Ser.rb +446 -441
- data/lib/ArangoRB_Task.rb +129 -113
- data/lib/ArangoRB_Tra.rb +169 -142
- data/lib/ArangoRB_Tran.rb +68 -53
- data/lib/ArangoRB_User.rb +149 -136
- data/lib/ArangoRB_Ver.rb +162 -147
- data/lib/arangorb.rb +16 -15
- data/spec/arangoRB_helper.rb +4 -4
- data/spec/arangoRestart_helper.rb +14 -14
- data/spec/lib/0.1.0/arangoAQL_helper.rb +64 -64
- data/spec/lib/0.1.0/arangoC_helper.rb +170 -170
- data/spec/lib/0.1.0/arangoDB_helper.rb +119 -119
- data/spec/lib/0.1.0/arangoDoc_helper.rb +79 -79
- data/spec/lib/0.1.0/arangoE_helper.rb +50 -50
- data/spec/lib/0.1.0/arangoG_helper.rb +78 -78
- data/spec/lib/0.1.0/arangoS_helper.rb +37 -37
- data/spec/lib/0.1.0/arangoT_helper.rb +48 -48
- data/spec/lib/0.1.0/arangoV_helper.rb +65 -65
- data/spec/lib/1.0.0/arangoC_helper.rb +73 -73
- data/spec/lib/1.0.0/arangoDB_helper.rb +48 -48
- data/spec/lib/1.0.0/arangoI_helper.rb +43 -43
- data/spec/lib/1.0.0/arangoS_helper.rb +192 -192
- data/spec/lib/1.0.0/arangoTa_helper.rb +49 -49
- data/spec/lib/1.0.0/arangoTr_helper.rb +15 -15
- data/spec/lib/1.0.0/arangoU_helper.rb +72 -72
- data/spec/lib/1.1.0/arangoRB_helper.rb +144 -144
- data/spec/lib/1.1.0/arangoRB_walks_helper.rb +19 -19
- data/spec/lib/1.2.0/arangoCache_helper.rb +66 -66
- data/spec/lib/1.3.0/arangoHash_helper.rb +30 -0
- data/spec/lib/arangoRB_0.1.0_helper.rb +9 -9
- data/spec/lib/arangoRB_1.0.0_helper.rb +6 -6
- data/spec/lib/arangoRB_1.1.0_helper.rb +2 -2
- data/spec/lib/arangoRB_1.2.0_helper.rb +2 -1
- data/spec/spec_helper.rb +41 -41
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d54851cdef40b35916f72673a1501f5d5f74871a
|
4
|
+
data.tar.gz: 4b453ff4829696fa34e9b8d5db2c09ce73069a95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dca119efd2bdc23accf16a0e3169f3a67e95fb1cee43924d2156aa3a6f205d8c6890751b2508afc10971694195ef944bc493250a51d1703dee2c1b6779ac85af
|
7
|
+
data.tar.gz: 14b701df1c161236be807c53e67e9a52a9bab3d13e8f51035ebabdbe38731bd5e2fa140b8f6187ac2ba28aaf342b30a7b2995ee336f70d50f97352715caa9403
|
data/ArangoRB.gemspec
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
# lib = File.expand_path('../lib', __FILE__)
|
2
|
-
# $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require "rake"
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = 'arangorb'
|
7
|
-
s.version = '1.
|
8
|
-
s.authors = ['Stefano Martin']
|
9
|
-
s.email = ['stefano@seluxit.com']
|
10
|
-
s.homepage = 'https://github.com/StefanoMartin/ArangoRB'
|
11
|
-
s.license = 'MIT'
|
12
|
-
s.summary = 'A simple ruby client for ArangoDB'
|
13
|
-
s.description = "
|
14
|
-
s.platform = Gem::Platform::RUBY
|
15
|
-
s.require_paths = ['lib']
|
16
|
-
s.files = FileList['lib/*', 'spec/**/*', 'ArangoRB.gemspec', 'Gemfile', 'LICENSE', 'README.md'].to_a
|
17
|
-
s.add_dependency 'httparty', '~> 0.14', '>= 0.14.0'
|
18
|
-
end
|
1
|
+
# lib = File.expand_path('../lib', __FILE__)
|
2
|
+
# $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "rake"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'arangorb'
|
7
|
+
s.version = '1.3.0'
|
8
|
+
s.authors = ['Stefano Martin']
|
9
|
+
s.email = ['stefano@seluxit.com']
|
10
|
+
s.homepage = 'https://github.com/StefanoMartin/ArangoRB'
|
11
|
+
s.license = 'MIT'
|
12
|
+
s.summary = 'A simple ruby client for ArangoDB'
|
13
|
+
s.description = "Ruby driver for ArangoDB's HTTP API"
|
14
|
+
s.platform = Gem::Platform::RUBY
|
15
|
+
s.require_paths = ['lib']
|
16
|
+
s.files = FileList['lib/*', 'spec/**/*', 'ArangoRB.gemspec', 'Gemfile', 'LICENSE', 'README.md'].to_a
|
17
|
+
s.add_dependency 'httparty', '~> 0.14', '>= 0.14.0'
|
18
|
+
end
|
data/Gemfile
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
gem "httparty", "~>0.14.0"
|
4
|
-
|
5
|
-
group :development, :test do
|
6
|
-
gem "rspec", "~>3.5"
|
7
|
-
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gem "httparty", "~>0.14.0"
|
4
|
+
|
5
|
+
group :development, :test do
|
6
|
+
gem "rspec", "~>3.5"
|
7
|
+
gem "awesome_print", "~>1.7"
|
8
|
+
end
|
data/LICENSE
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2016 StefanoMartin
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 StefanoMartin
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,867 +1,906 @@
|
|
1
|
-
ArangoRB [![Gem Version](https://badge.fury.io/rb/arangorb.svg)](https://badge.fury.io/rb/arangorb)
|
2
|
-
===============================
|
3
|
-
|
4
|
-
[ArangoDatabase](https://www.arangodb.com/) is a native multi-model database with flexible data models for document, graphs, and key-values.
|
5
|
-
ArangoRB is a Gem to use ArangoDatabase with Ruby. ArangoRB is based on the [HTTP API of ArangoDB](https://docs.arangodb.com/3.0/HTTP/index.html).
|
6
|
-
|
7
|
-
ArangoRB has been tested with ArangoDatabase 3.0 on Ruby 2.3.1. It requires the gem "HTTParty"
|
8
|
-
|
9
|
-
To install ArangoRB: `gem install arangorb`
|
10
|
-
|
11
|
-
To use it in your application: `require "arangorb"`
|
12
|
-
|
13
|
-
This Gem was created from [Seluxit ApS](http://seluxit.com/).
|
14
|
-
|
15
|
-
## Classes used
|
16
|
-
|
17
|
-
ArangoRB has the following classes.
|
18
|
-
|
19
|
-
* [ArangoServer](#ArangoServer): to manage the global variables for the management of the database
|
20
|
-
* [ArangoDatabase](#ArangoDatabase): to manage Databases
|
21
|
-
* [ArangoCollection](#ArangoCollection): to manage Collections
|
22
|
-
* [ArangoDocument](#ArangoDocument): to manage Documents
|
23
|
-
* [ArangoVertex](#ArangoVertex): to manage Vertexes
|
24
|
-
* [ArangoEdge](#ArangoEdge): to manage Edges
|
25
|
-
* [ArangoGraph](#ArangoGraph): to manage Graphs
|
26
|
-
* [ArangoTraversal](#ArangoTraversal): to manage Traversal operations
|
27
|
-
* [ArangoAQL](#arangoaql): to manage AQL instances
|
28
|
-
* [ArangoUser](#ArangoUser): to manage Users
|
29
|
-
* [ArangoIndex](#ArangoIndex): to manage Indexes
|
30
|
-
* [ArangoTask](#ArangoTask): to manage Tasks
|
31
|
-
* [ArangoTransaction](#ArangoTransaction): to manage Transactions
|
32
|
-
* [ArangoCache](#ArangoCache): to manage a cache on your Computer
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
ArangoServer
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
ArangoServer
|
56
|
-
|
57
|
-
|
58
|
-
ArangoServer.
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
ArangoServer.
|
82
|
-
ArangoServer.
|
83
|
-
ArangoServer.
|
84
|
-
ArangoServer.
|
85
|
-
ArangoServer.
|
86
|
-
ArangoServer.
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
ArangoServer.
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
ArangoServer.
|
105
|
-
ArangoServer.
|
106
|
-
ArangoServer.
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
ArangoServer
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
ArangoServer
|
124
|
-
|
125
|
-
|
126
|
-
ArangoServer.
|
127
|
-
#
|
128
|
-
ArangoServer.
|
129
|
-
ArangoServer.
|
130
|
-
|
131
|
-
ArangoServer.
|
132
|
-
ArangoServer.
|
133
|
-
|
134
|
-
ArangoServer.
|
135
|
-
ArangoServer.
|
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
|
-
ArangoServer.
|
174
|
-
ArangoServer.
|
175
|
-
ArangoServer.
|
176
|
-
ArangoServer.
|
177
|
-
ArangoServer.
|
178
|
-
ArangoServer.
|
179
|
-
ArangoServer.
|
180
|
-
ArangoServer.
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
```
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
ArangoServer.
|
199
|
-
ArangoServer.
|
200
|
-
ArangoServer.
|
201
|
-
ArangoServer.
|
202
|
-
ArangoServer.
|
203
|
-
ArangoServer.
|
204
|
-
ArangoServer.
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
ArangoDatabase
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
```
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
```
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
myDatabase.
|
258
|
-
myDatabase.
|
259
|
-
myDatabase.
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
```
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
```
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
`myCollection.
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
myCollection
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
myCollection.
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
```
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
``` ruby
|
400
|
-
|
401
|
-
|
402
|
-
myCollection.
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
myCollection.
|
418
|
-
```
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
myCollection.
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
myDocument = ArangoDocument.new
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
```
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
ArangoDocument.
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
```
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
* [myDocA] --(
|
534
|
-
* [myDocB] --(
|
535
|
-
* [myDocA] --(
|
536
|
-
* [myDocB] --(
|
537
|
-
|
538
|
-
``` ruby
|
539
|
-
myEdgeCollection.create_edge document: myEdge, from: [myDocA, myDocB], to: [myDocC, myDocD]
|
540
|
-
```
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
* A
|
582
|
-
* A
|
583
|
-
*
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
```
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
myGraph
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
myGraph.
|
627
|
-
myGraph.
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
###
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
###
|
654
|
-
|
655
|
-
|
656
|
-
To use
|
657
|
-
|
658
|
-
``` ruby
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
```
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
```
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
```
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
myQuery.
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
```
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
```
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
```
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
```
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
``` ruby
|
783
|
-
|
784
|
-
```
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
```
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
ArangoCache.
|
833
|
-
ArangoCache.
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
ArangoCache.
|
849
|
-
```
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
1
|
+
ArangoRB [![Gem Version](https://badge.fury.io/rb/arangorb.svg)](https://badge.fury.io/rb/arangorb)
|
2
|
+
===============================
|
3
|
+
|
4
|
+
[ArangoDatabase](https://www.arangodb.com/) is a native multi-model database with flexible data models for document, graphs, and key-values.
|
5
|
+
ArangoRB is a Gem to use ArangoDatabase with Ruby. ArangoRB is based on the [HTTP API of ArangoDB](https://docs.arangodb.com/3.0/HTTP/index.html).
|
6
|
+
|
7
|
+
ArangoRB has been tested with ArangoDatabase 3.0 on Ruby 2.3.1. It requires the gem "HTTParty"
|
8
|
+
|
9
|
+
To install ArangoRB: `gem install arangorb`
|
10
|
+
|
11
|
+
To use it in your application: `require "arangorb"`
|
12
|
+
|
13
|
+
This Gem was created from [Seluxit ApS](http://seluxit.com/).
|
14
|
+
|
15
|
+
## Classes used
|
16
|
+
|
17
|
+
ArangoRB has the following classes.
|
18
|
+
|
19
|
+
* [ArangoServer](#ArangoServer): to manage the global variables for the management of the database
|
20
|
+
* [ArangoDatabase](#ArangoDatabase): to manage Databases
|
21
|
+
* [ArangoCollection](#ArangoCollection): to manage Collections
|
22
|
+
* [ArangoDocument](#ArangoDocument): to manage Documents
|
23
|
+
* [ArangoVertex](#ArangoVertex): to manage Vertexes
|
24
|
+
* [ArangoEdge](#ArangoEdge): to manage Edges
|
25
|
+
* [ArangoGraph](#ArangoGraph): to manage Graphs
|
26
|
+
* [ArangoTraversal](#ArangoTraversal): to manage Traversal operations
|
27
|
+
* [ArangoAQL](#arangoaql): to manage AQL instances
|
28
|
+
* [ArangoUser](#ArangoUser): to manage Users
|
29
|
+
* [ArangoIndex](#ArangoIndex): to manage Indexes
|
30
|
+
* [ArangoTask](#ArangoTask): to manage Tasks
|
31
|
+
* [ArangoTransaction](#ArangoTransaction): to manage Transactions
|
32
|
+
* [ArangoCache](#ArangoCache): to manage a cache on your Computer
|
33
|
+
* [ArangoReplication](#ArangoReplication): to manage Replications
|
34
|
+
|
35
|
+
NB: All the instances of these classes (with the exception of ArangoCache) can be transformed in Hash with the command to_h.
|
36
|
+
|
37
|
+
<a name="ArangoServer"></a>
|
38
|
+
## ArangoServer
|
39
|
+
|
40
|
+
ArangoServer is used to manage the default Database, Collection, User and Graph.
|
41
|
+
It is used to give your login credentials and it is the mandatory step to start your database.
|
42
|
+
Further it helps to manage the Server connected with ArangoDB.
|
43
|
+
|
44
|
+
To setup your credentials use:
|
45
|
+
|
46
|
+
``` ruby
|
47
|
+
ArangoServer.default_server user: "MyUsername", password: "MyPassword", server: "localhost", port: "8529"
|
48
|
+
```
|
49
|
+
|
50
|
+
If not declared, the default values are user: "root", password: "", server: "localhost", port: "8529".
|
51
|
+
|
52
|
+
### Default variables
|
53
|
+
|
54
|
+
Databases, Graphs and Collections used in your program can be defined each time. But often it is convenient to have some default one.
|
55
|
+
If this is the case, the user can use ArangoServer to define some default values.
|
56
|
+
|
57
|
+
``` ruby
|
58
|
+
ArangoServer.database = "MyDatabase" # Setup default Database
|
59
|
+
ArangoServer.graph = "MyGraph" # Setup default Graph
|
60
|
+
ArangoServer.collection = "MyCollection" # Setup default Collection
|
61
|
+
ArangoServer.user = "MyUser" # Setup default User
|
62
|
+
```
|
63
|
+
|
64
|
+
By default the default database is "\_system".
|
65
|
+
|
66
|
+
### Verbose
|
67
|
+
|
68
|
+
For Debugging reasons the user can receive the original JSON file from the database by setting verbose on true (false by default).
|
69
|
+
|
70
|
+
``` ruby
|
71
|
+
ArangoServer.verbose = true
|
72
|
+
```
|
73
|
+
|
74
|
+
Remember that verbose is only for testing reason: to work efficiently verbose should be false.
|
75
|
+
|
76
|
+
### Information
|
77
|
+
|
78
|
+
Basic informations can be retrieved with these command.
|
79
|
+
|
80
|
+
``` ruby
|
81
|
+
ArangoServer.database # Check name default Database
|
82
|
+
ArangoServer.graph # Check name default Graph
|
83
|
+
ArangoServer.collection # Check name default Collection
|
84
|
+
ArangoServer.user # Check name default User
|
85
|
+
ArangoServer.address # Check address used to connect with the server
|
86
|
+
ArangoServer.username # Check name used to connect with the server
|
87
|
+
ArangoServer.verbose # Check if verbose is true or false
|
88
|
+
ArangoServer.async # Check the status of async
|
89
|
+
ArangoServer.request # Check the default request sent to the server
|
90
|
+
```
|
91
|
+
|
92
|
+
To retrieve lists
|
93
|
+
|
94
|
+
``` ruby
|
95
|
+
ArangoServer.endpoints # Lists of endpoints used
|
96
|
+
ArangoServer.users # Lists of available users
|
97
|
+
ArangoServer.databases # Lists of available databases
|
98
|
+
ArangoServer.tasks # Lists of available tasks
|
99
|
+
```
|
100
|
+
|
101
|
+
To monitoring the server you can use the following commands
|
102
|
+
|
103
|
+
``` ruby
|
104
|
+
ArangoServer.log # Return log files
|
105
|
+
ArangoServer.reload # Reloads the routing information from the collection routing.
|
106
|
+
ArangoServer.statistics # Returns the statistics information
|
107
|
+
ArangoServer.statistics description: true # Fetch descriptive info of statistics
|
108
|
+
ArangoServer.role # Get to know whether this server is a Coordinator or DB-Server
|
109
|
+
ArangoServer.serverId # Fetch this servers uniq identifier
|
110
|
+
```
|
111
|
+
|
112
|
+
### Manage Async
|
113
|
+
|
114
|
+
With ArangoServer you can manage Async results.
|
115
|
+
|
116
|
+
``` ruby
|
117
|
+
ArangoServer.async = false # default
|
118
|
+
ArangoServer.async = true # fire and forget
|
119
|
+
ArangoServer.async = "store" # fire and store
|
120
|
+
```
|
121
|
+
|
122
|
+
If Async is "store", then the commands of ArangoRB will return the id of the Async requests.
|
123
|
+
ArangoServer provides different methods to manage these Async requests.
|
124
|
+
|
125
|
+
``` ruby
|
126
|
+
ArangoServer.pendingAsync # Querying the status of a pending job
|
127
|
+
ArangoServer.fetchAsync id: id # Fetches a job result and removes it from the queue
|
128
|
+
ArangoServer.retrieveAsync id: id # Returns the status of a specific job
|
129
|
+
ArangoServer.retrieveAsync type: type # Returns the ids of job results with a specific status
|
130
|
+
# Type can be "done" or "pending"
|
131
|
+
ArangoServer.retrieveDoneAsync # Equivalent to ArangoServer.retrieveAsync type: "done"
|
132
|
+
ArangoServer.retrievePendingAsync # Equivalent to ArangoServer.retrieveAsync type: "pending"
|
133
|
+
ArangoServer.cancelAsync id: id # Cancels an async job
|
134
|
+
ArangoServer.destroyAsync id: id # Deletes an async job result
|
135
|
+
ArangoServer.destroyAsync type: type # Deletes async jobs with a specific status
|
136
|
+
# Type can be "all" or "expired"
|
137
|
+
ArangoServer.destroyAllAsync # Equivalent to ArangoServer.destroyAsync type: "all"
|
138
|
+
ArangoServer.destroyExpiredAsync # Equivalent to ArangoServer.destroyAsync type: "expired"
|
139
|
+
```
|
140
|
+
|
141
|
+
### Batch
|
142
|
+
|
143
|
+
ArangoDB offers a batch request API that clients can use to send multiple operations in one batch to ArangoDB. To manage it you can use the following way.
|
144
|
+
|
145
|
+
``` ruby
|
146
|
+
queries = [
|
147
|
+
{
|
148
|
+
"type": "POST",
|
149
|
+
"address": "/_db/MyDatabase/_api/collection",
|
150
|
+
"body": {"name": "newCOLLECTION"},
|
151
|
+
"id": "1"
|
152
|
+
},
|
153
|
+
{
|
154
|
+
"type": "GET",
|
155
|
+
"address": "/_api/database",
|
156
|
+
"id": "2"
|
157
|
+
}
|
158
|
+
]
|
159
|
+
ArangoServer.batch queries: queries
|
160
|
+
```
|
161
|
+
|
162
|
+
To manage these batch, ArangoServer offers the following functions:
|
163
|
+
|
164
|
+
``` ruby
|
165
|
+
ArangoServer.createDumpBatch ttl: 10 # Create a new dump batch with 10 second time-to-live (return id of the dumpBatch)
|
166
|
+
ArangoServer.prolongDumpBatch id: idDumpBatch, ttl: 20 # Prolong the life of a batch for 20 seconds
|
167
|
+
ArangoServer.destroyDumpBatch id: idDumpBatch # Delete a selected batch
|
168
|
+
```
|
169
|
+
|
170
|
+
### Miscellaneous
|
171
|
+
|
172
|
+
``` ruby
|
173
|
+
ArangoServer.version # Returns the server version number
|
174
|
+
ArangoServer.flushWAL # Flushes the write-ahead log
|
175
|
+
ArangoServer.propertyWAL # Retrieves the configuration of the write-ahead log
|
176
|
+
ArangoServer.changePropertyWAL # Configures the write-ahead log
|
177
|
+
ArangoServer.transactions # Returns information about the currently running transactions
|
178
|
+
ArangoServer.time # Get the current time of the system
|
179
|
+
ArangoServer.echo # Return current request
|
180
|
+
ArangoServer.databaseVersion # Return the required version of the database
|
181
|
+
ArangoServer.sleep duration: 10 # Sleep for a specified amount of seconds
|
182
|
+
ArangoServer.shutdown # Initiate shutdown sequence
|
183
|
+
ArangoServer.restart # Restart ArangoDB (requires administration access)
|
184
|
+
```
|
185
|
+
|
186
|
+
UNTESTED
|
187
|
+
|
188
|
+
``` ruby
|
189
|
+
ArangoServer.test body: body # Runs tests on server
|
190
|
+
ArangoServer.execute body: body # Execute a script on the server.
|
191
|
+
```
|
192
|
+
|
193
|
+
### Sharding (UNTESTED)
|
194
|
+
|
195
|
+
ArangoDB permits the sharding of the database. Although these methods has not been tested with ArangoRB.
|
196
|
+
|
197
|
+
``` ruby
|
198
|
+
ArangoServer.cluster # Default cluster
|
199
|
+
ArangoServer.getCluster body: body, cluster: cluster # Retrieve cluster
|
200
|
+
ArangoServer.executeCluster body: body, cluster: cluster # Execute cluster
|
201
|
+
ArangoServer.executeClusterPut body: body, cluster: cluster # Execute cluster
|
202
|
+
ArangoServer.executeClusterHead body: body, cluster: cluster # Execute cluster
|
203
|
+
ArangoServer.destroyCluster cluster: cluster # Delete cluster
|
204
|
+
ArangoServer.updateCluster body: body, cluster: cluster # Update cluster
|
205
|
+
ArangoServer.checkPort port: port # Allows to check whether a given port is usable
|
206
|
+
ArangoServer.server # Returns the id of a server in a cluster.
|
207
|
+
ArangoServer.clusterStatistics dbserver: dbserver # Allows to query the statistics of a DBserver in the cluster
|
208
|
+
```
|
209
|
+
|
210
|
+
<a name="ArangoDatabase"></a>
|
211
|
+
## ArangoDatabase
|
212
|
+
|
213
|
+
ArangoDatabase is used to manage your Database. You can create an instance in the following way:
|
214
|
+
|
215
|
+
``` ruby
|
216
|
+
myDatabase = ArangoDatabase.new database: "MyDatabase"
|
217
|
+
```
|
218
|
+
|
219
|
+
Alternatively, you can use the default values provided by ArangoServer:
|
220
|
+
|
221
|
+
``` ruby
|
222
|
+
ArangoServer.database = "MyDatabase"
|
223
|
+
myDatabase = ArangoDatabase.new
|
224
|
+
```
|
225
|
+
|
226
|
+
### Create and Destroy a Database
|
227
|
+
|
228
|
+
``` ruby
|
229
|
+
myDatabase.create # Create a new Database
|
230
|
+
myDatabase.destroy # Delete the selected Database
|
231
|
+
```
|
232
|
+
|
233
|
+
### Retrieve information
|
234
|
+
|
235
|
+
``` ruby
|
236
|
+
ArangoDatabase.info # Obtain general info about the databases
|
237
|
+
ArangoDatabase.databases # Obtain an Array with the available databases
|
238
|
+
myDatabase.collections # Obtain an Array with the available collections in the selected Database
|
239
|
+
myDatabase.graphs # Obtain an Array with the available graphs in the selected Database
|
240
|
+
myDatabase.functions # Obtain an Array with the available functions in the selected Database
|
241
|
+
```
|
242
|
+
|
243
|
+
It is possible to access its Collections and Graphs by their ids.
|
244
|
+
|
245
|
+
``` ruby
|
246
|
+
myDatabase["MyCollection"].retrieve # where "MyCollection" is the id of the collection
|
247
|
+
myDatabase.collection("MyCollection").retrieve
|
248
|
+
myDatabase.graph("MyGraph").retrieve
|
249
|
+
```
|
250
|
+
|
251
|
+
|
252
|
+
### Query
|
253
|
+
|
254
|
+
ArangoDatabase instances can manage the queries used in their Database.
|
255
|
+
|
256
|
+
``` ruby
|
257
|
+
myDatabase.propertiesQuery; # See property of the Query
|
258
|
+
myDatabase.currentQuery; # Check the current Query
|
259
|
+
myDatabase.slowQuery; # Find slow queries
|
260
|
+
myDatabase.stopSlowQuery; # Stop slow queries
|
261
|
+
myDatabase.kill query: myQuery # Kill a Query
|
262
|
+
myDatabase.changePropertiesQuery maxSlowQueries: 65 # Change properties of a Query
|
263
|
+
```
|
264
|
+
|
265
|
+
### Cache
|
266
|
+
|
267
|
+
To manage the cache ArangoDatabase provides the following three functions.
|
268
|
+
|
269
|
+
``` ruby
|
270
|
+
myDatabase.clearCache # Clear Cache
|
271
|
+
myDatabase.propertyCache # Check properties Cache
|
272
|
+
myDatabase.changePropertyCache maxResults: 30 # Change properties Cache
|
273
|
+
```
|
274
|
+
|
275
|
+
### AQL Functions
|
276
|
+
|
277
|
+
``` ruby
|
278
|
+
myDatabase.createFunction code: "function(){return 1+1;}", name: "myFunction" # Create a new Function
|
279
|
+
myDatabase.deleteFunction name: "myFunction" # Delete a function
|
280
|
+
myDatabase.functions # Retrieve a list of the available functions
|
281
|
+
```
|
282
|
+
|
283
|
+
### User
|
284
|
+
|
285
|
+
You can manage the right of a user to access the database.
|
286
|
+
|
287
|
+
``` ruby
|
288
|
+
myDatabase.grant user: myUser # Grant access to database
|
289
|
+
myDatabase.revoke user: myUser # Revoke access to database
|
290
|
+
```
|
291
|
+
|
292
|
+
<a name="ArangoCollection"></a>
|
293
|
+
## ArangoCollection
|
294
|
+
|
295
|
+
ArangoDatabase is used to manage your Collections. You can create an ArangoCollection instance in one of the following way:
|
296
|
+
|
297
|
+
``` ruby
|
298
|
+
myCollection = ArangoCollection.new database: "MyDatabase", collection: "MyCollection"
|
299
|
+
myCollection = ArangoCollection.new collection: "MyCollection" # Using the default database
|
300
|
+
myCollection = ArangoCollection.new # Using the default database and collection
|
301
|
+
```
|
302
|
+
|
303
|
+
A Collection can be of two types: "Document" and "Edge". If you want to specify it, uses:
|
304
|
+
|
305
|
+
``` ruby
|
306
|
+
myCollectionA = ArangoCollection.new collection: "MyCollectionA", type: "Document"
|
307
|
+
myCollectionB = ArangoCollection.new collection: "MyCollectionB", type: "Edge"
|
308
|
+
```
|
309
|
+
|
310
|
+
### Create a Collection
|
311
|
+
|
312
|
+
`myCollection.create`
|
313
|
+
|
314
|
+
If not specified the default type of the Collection is "Document".
|
315
|
+
To create an Edge Collection you can use one of the next three options:
|
316
|
+
|
317
|
+
``` ruby
|
318
|
+
myCollection.create_edge_collection
|
319
|
+
myCollection.create type: "Edge"
|
320
|
+
myCollectionB = ArangoCollection.new collection: "MyCollectionB", type: "Edge"; myCollectionB.create
|
321
|
+
```
|
322
|
+
|
323
|
+
### Destroy or Truncate a Collections
|
324
|
+
|
325
|
+
Destroy will delete the selected Collection from the Database.
|
326
|
+
|
327
|
+
`myCollection.destroy`
|
328
|
+
|
329
|
+
Truncate will delete all the Documents inside the selected Collection.
|
330
|
+
|
331
|
+
`myCollection.truncate`
|
332
|
+
|
333
|
+
### Retrieve information
|
334
|
+
|
335
|
+
It is possible to access its Documents and its database.
|
336
|
+
|
337
|
+
``` ruby
|
338
|
+
myCollection["MyDocument"]
|
339
|
+
myDatabase.document("MyDocument")
|
340
|
+
myDatabase.database
|
341
|
+
```
|
342
|
+
|
343
|
+
For other information
|
344
|
+
|
345
|
+
``` ruby
|
346
|
+
myCollection.retrieve # Retrieve the selected Collection
|
347
|
+
myCollection.indexes # Return a list of all used Indexes in the Collection
|
348
|
+
myCollection.data # Returns the whole content of one collection
|
349
|
+
myCollection.properties # Properties of the Collection
|
350
|
+
myCollection.count # Number of Documents in the Collection
|
351
|
+
myCollection.stats # Statistics of the Collection
|
352
|
+
myCollection.revision # Return collection revision id
|
353
|
+
myCollection.checksum # Return checksum for the Collection
|
354
|
+
```
|
355
|
+
|
356
|
+
To retrieve all the documents of a Collection you can use:
|
357
|
+
|
358
|
+
``` ruby
|
359
|
+
myCollection.documents
|
360
|
+
myCollection.allDocuments
|
361
|
+
```
|
362
|
+
|
363
|
+
These two functions are similar except for the fact that you can assign different variables.
|
364
|
+
|
365
|
+
`myCollection.documents type: "path"`
|
366
|
+
|
367
|
+
Type can be "path", "id" or "key" in relation what we wish to have. If not specified we will receive an array of ArangoDocument instances.
|
368
|
+
|
369
|
+
`myCollection.allDocuments skip: 3, limit: 100, batchSize: 10`
|
370
|
+
|
371
|
+
It means that we skip the first three Documents, we can retrieve the next 100 Documents but we return only the first ten.
|
372
|
+
|
373
|
+
To retrieve specific Document you can use:
|
374
|
+
|
375
|
+
``` ruby
|
376
|
+
myCollection.documentsMatch match: {"value" => 4} # All Documents of the Collection with value equal to 4
|
377
|
+
myCollection.documentMatch match: {"value" => 4} # The first Document of the Collection with value equal to 4
|
378
|
+
myCollection.documentByKeys keys: ["4546", "4646"] # Documents of the Collection with the keys in the Array
|
379
|
+
myCollection.random # A random Document of the Collection
|
380
|
+
```
|
381
|
+
|
382
|
+
### Modify the Collection
|
383
|
+
|
384
|
+
``` ruby
|
385
|
+
myCollection.load # Load the Collection
|
386
|
+
myCollection.unload # Unload the Collection
|
387
|
+
myCollection.change waitForSync: true # Change a property of the Collection
|
388
|
+
myCollection.rename "myCollectionC" # Rename the Collection
|
389
|
+
myCollection.rotate # Rotate journal of a collection
|
390
|
+
```
|
391
|
+
|
392
|
+
### Import and Export Documents
|
393
|
+
|
394
|
+
For the standard way to import one or more Documents (or Edges) we refer to the [dedicated ArangoDocument section](#create_doc).
|
395
|
+
However it is possible to import a huge quantity of documents in a Collection with only one requests with the command import.
|
396
|
+
|
397
|
+
<strong>Import one Document with Array</strong>
|
398
|
+
I import one document with the following structure {"value": "uno", "num": 1, "name": "ONE"}.
|
399
|
+
``` ruby
|
400
|
+
attributes = ["value", "num", "name"]
|
401
|
+
values = ["uno",1,"ONE"]
|
402
|
+
myCollection.import attributes: attributes, values: values
|
403
|
+
```
|
404
|
+
|
405
|
+
<strong>Import more Documents with Array</strong>
|
406
|
+
I import three Documents with the following structure {"value": "uno", "num": 1, "name": "ONE"}, {"value": "due", "num": 2, "name": "TWO"}, {"value": "tre", "num": 3, "name": "THREE"}.
|
407
|
+
``` ruby
|
408
|
+
attributes = ["value", "num", "name"]
|
409
|
+
values = [["uno",1,"ONE"],["due",2,"TWO"],["tre",3,"THREE"]]
|
410
|
+
myCollection.import attributes: attributes, values: values
|
411
|
+
```
|
412
|
+
|
413
|
+
<strong>Import more Documents with JSON</strong>
|
414
|
+
I import two Documents with the following structure {"value": "uno", "num": 1, "name": "ONE"}, {"value": "due", "num": 2, "name": "TWO"}.
|
415
|
+
``` ruby
|
416
|
+
body = [{"value": "uno", "num": 1, "name": "ONE"}, {"value": "due", "num": 2, "name": "DUE"}]
|
417
|
+
myCollection.importJSON body: body
|
418
|
+
```
|
419
|
+
|
420
|
+
As it is possible to import files, it is possible to export all the Document of a Collection with the following command.
|
421
|
+
``` ruby
|
422
|
+
myCollection.export
|
423
|
+
```
|
424
|
+
|
425
|
+
Alternatively it is possible to retrieve all the Documents in a Collection gradually.
|
426
|
+
|
427
|
+
``` ruby
|
428
|
+
myCollection.export batchSize: 3 # First three Documents of the Collection
|
429
|
+
myCollection.exportNext # Next three Documents
|
430
|
+
myCollection.exportNext # Next three Documents
|
431
|
+
```
|
432
|
+
|
433
|
+
### Other operations
|
434
|
+
|
435
|
+
``` ruby
|
436
|
+
myCollection.removeByKeys keys: ["4546", "4646"] # Documents of the Collection with the keys in the Array will be removed
|
437
|
+
myCollection.removeMatch match: {"value" => 4} # All Documents of the Collection with value equal to 4 will be removed
|
438
|
+
myCollection.replaceMatch match: {"value" => 4}, newValue: {"value" => 6} # All Documents of the Collection with value equal to 4 will be replaced with the new Value
|
439
|
+
myCollection.updateMatch match: {"value" => 4}, newValue: {"value" => 6} # All Documents of the Collection with value equal to 4 will be updated with the new Value
|
440
|
+
```
|
441
|
+
|
442
|
+
<a name="ArangoDocument"></a>
|
443
|
+
## ArangoDocument
|
444
|
+
|
445
|
+
An Arango Document is an element of a Collection. Edges are documents with "\_from" and "\_to" in their body.
|
446
|
+
You can create an ArangoCollection instance in one of the following way:
|
447
|
+
|
448
|
+
``` ruby
|
449
|
+
myDocument = ArangoDocument.new database: "MyDatabase", collection: "MyCollection", key: "myKey"
|
450
|
+
myDocument = ArangoDocument.new collection: "MyCollection", key: "myKey" # Using default Database
|
451
|
+
myDocument = ArangoDocument.new key: "myKey" # Using default Collection and Database
|
452
|
+
myDocument = ArangoDocument.new # Using default Collection and Database and I don't want to define a key for my Instance
|
453
|
+
```
|
454
|
+
|
455
|
+
In the case you want to define a Edge, it is convenient to introduce the parameters "from" and "to" in the instance.
|
456
|
+
|
457
|
+
``` ruby
|
458
|
+
myEdge = ArangoDocument.new from: myDocA, to: myDocB
|
459
|
+
```
|
460
|
+
|
461
|
+
where myDocA and myDocB are the IDs of two Documents or are two ArangoDocument instances.
|
462
|
+
During the instance, it is possible to define a Body for the Document.
|
463
|
+
|
464
|
+
``` ruby
|
465
|
+
myDocument = ArangoDocument.new body: {"value" => 17}
|
466
|
+
```
|
467
|
+
|
468
|
+
<a name="create_doc"></a>
|
469
|
+
### Create one or more Documents
|
470
|
+
|
471
|
+
ArangoRB provides several way to create a single Document.
|
472
|
+
|
473
|
+
``` ruby
|
474
|
+
myDocument.create
|
475
|
+
myCollection.create_document document: myDocument # myDocument is an ArangoDocument instance or a Hash
|
476
|
+
ArangoDocument.create body: {"value" => 17}, collection: myDocument
|
477
|
+
```
|
478
|
+
|
479
|
+
Or more Documents.
|
480
|
+
|
481
|
+
``` ruby
|
482
|
+
myCollection.create_document document: [myDocumentA, myDocumentB, {"value" => 17}] # Array of ArangoDocument instances and Hashes
|
483
|
+
ArangoDocument.create body: [myDocumentA, {"value" => 18}, {"value" => 3}], collection: myDocument # Array of ArangoDocument instances and Hash
|
484
|
+
```
|
485
|
+
|
486
|
+
### Create one or more Edges
|
487
|
+
|
488
|
+
ArangoRB has different way to create one or multiple edges. Here some example:
|
489
|
+
|
490
|
+
``` ruby
|
491
|
+
myEdge = ArangoDocument.new from: myDocA, to: myDocB; myEdge.create
|
492
|
+
myEdge.create_edge from: myDocA, to: myDocB # myDocA and myDocB are ArangoDocument ids or ArangoDocument instances
|
493
|
+
myEdgeCollection.create_edge document: myEdge, from: myDocA, to: myDocB
|
494
|
+
ArangoDocument.create_edge body: {"value" => 17}, from: myDocA, to: myDocB, collection: myEdgeCollection
|
495
|
+
```
|
496
|
+
|
497
|
+
Further we have the possibility to create different combination of Edges in only one line of code
|
498
|
+
|
499
|
+
One-to-one with one Edge class
|
500
|
+
|
501
|
+
* [myDocA] --(myEdge)--> [myDocB]
|
502
|
+
|
503
|
+
``` ruby
|
504
|
+
myEdgeCollection.create_edge document: myEdge, from: myDocA, to: myDocB
|
505
|
+
```
|
506
|
+
|
507
|
+
One-to-more with one Edge class (and More-to-one with one Edge class)
|
508
|
+
|
509
|
+
* [myDocA] --(myEdge)--> [myDocB]
|
510
|
+
* [myDocA] --(myEdge)--> [myDocC]
|
511
|
+
|
512
|
+
``` ruby
|
513
|
+
myEdgeCollection.create_edge document: myEdge, from: myDocA, to: [myDocB, myDocC]
|
514
|
+
```
|
515
|
+
|
516
|
+
More-to-More with one Edge class
|
517
|
+
|
518
|
+
* [myDocA] --(myEdge)--> [myDocC]
|
519
|
+
* [myDocB] --(myEdge)--> [myDocC]
|
520
|
+
* [myDocA] --(myEdge)--> [myDocD]
|
521
|
+
* [myDocB] --(myEdge)--> [myDocD]
|
522
|
+
|
523
|
+
``` ruby
|
524
|
+
myEdgeCollection.create_edge document: myEdge, from: [myDocA, myDocB], to: [myDocC, myDocD]
|
525
|
+
```
|
526
|
+
|
527
|
+
More-to-More with more Edge classes
|
528
|
+
|
529
|
+
* [myDocA] --(myEdge)--> [myDocC]
|
530
|
+
* [myDocB] --(myEdge)--> [myDocC]
|
531
|
+
* [myDocA] --(myEdge)--> [myDocD]
|
532
|
+
* [myDocB] --(myEdge)--> [myDocD]
|
533
|
+
* [myDocA] --(myEdge2)--> [myDocC]
|
534
|
+
* [myDocB] --(myEdge2)--> [myDocC]
|
535
|
+
* [myDocA] --(myEdge2)--> [myDocD]
|
536
|
+
* [myDocB] --(myEdge2)--> [myDocD]
|
537
|
+
|
538
|
+
``` ruby
|
539
|
+
myEdgeCollection.create_edge document: [myEdge, myEdge2], from: [myDocA, myDocB], to: [myDocC, myDocD]
|
540
|
+
```
|
541
|
+
|
542
|
+
### Destroy a Document
|
543
|
+
|
544
|
+
``` ruby
|
545
|
+
myDocument.destroy
|
546
|
+
```
|
547
|
+
|
548
|
+
### Retrieve information
|
549
|
+
|
550
|
+
``` ruby
|
551
|
+
myDocument.retrieve # Retrieve Document
|
552
|
+
myDocument.collection # Retrieve Collection of the Document
|
553
|
+
myDocument.database # Retrieve Database of the Document
|
554
|
+
myDocument.retrieve_edges collection: myEdgeCollection # Retrieve all myEdgeCollection edges connected with the Document
|
555
|
+
myDocument.any(myEdgeCollection) # Retrieve all myEdgeCollection edges connected with the Document
|
556
|
+
myDocument.in(myEdgeCollection) # Retrieve all myEdgeCollection edges coming in the Document
|
557
|
+
myDocument.out(myEdgeCollection) # Retrieve all myEdgeCollection edges going out the Document
|
558
|
+
myEdge.from # Retrieve the document at the begin of the edge
|
559
|
+
myEdge.to # Retrieve the document at the end of the edge
|
560
|
+
```
|
561
|
+
|
562
|
+
#### Example: how to navigate the edges
|
563
|
+
|
564
|
+
Think for example that we have the following schema:
|
565
|
+
* A --[class: a, name: aa]--> B
|
566
|
+
* A --[class: a, name: bb]--> C
|
567
|
+
* A --[class: b, name: cc]--> D
|
568
|
+
* B --[class: a, name: dd]--> E
|
569
|
+
|
570
|
+
Then we have:
|
571
|
+
|
572
|
+
* A.retrieve is A
|
573
|
+
* A.retrieve_edges(collection: a) is [aa, bb]
|
574
|
+
* B.any(a) is [aa, dd]
|
575
|
+
* B.in(a) is [aa]
|
576
|
+
* B.out(a) is [dd]
|
577
|
+
* aa.from is A
|
578
|
+
* aa.to is B
|
579
|
+
|
580
|
+
We can even do some combinations: for example A.out(a)[0].to.out(a)[0].to is E since:
|
581
|
+
* A.out(a) is [aa]
|
582
|
+
* A.out(a)[0] is aa
|
583
|
+
* A.out(a)[0].to is B
|
584
|
+
* A.out(a)[0].to.out(a) is [dd]
|
585
|
+
* A.out(a)[0].to.out(a)[0] is dd
|
586
|
+
* A.out(a)[0].to.out(a)[0].to is E
|
587
|
+
|
588
|
+
### Modify
|
589
|
+
|
590
|
+
``` ruby
|
591
|
+
myDocument.update body: {"value" => 3} # We update or add a value
|
592
|
+
myDocument.replace body: {"value" => 3} # We replace a value
|
593
|
+
```
|
594
|
+
|
595
|
+
<a name="ArangoGraph"></a>
|
596
|
+
## ArangoGraph
|
597
|
+
|
598
|
+
ArangoGraph are used to manage Graphs. You can create an ArangoGraph instance in one of the following way.
|
599
|
+
|
600
|
+
``` ruby
|
601
|
+
myGraph = ArangoGraph.new database: "MyDatabase", graph: "MyGraph"
|
602
|
+
myGraph = ArangoGraph.new graph: "MyGraph" # By using the default Database
|
603
|
+
myGraph = ArangoGraph.new # By using the defauly Database and Graph
|
604
|
+
```
|
605
|
+
|
606
|
+
### Create, Retrieve and Destroy a Graph
|
607
|
+
|
608
|
+
``` ruby
|
609
|
+
myGraph.create # create a new Graph
|
610
|
+
myGraph.retrieve # retrieve the Graph
|
611
|
+
myGraph.database # retrieve database of the Graph
|
612
|
+
myGraph.destroy # destroy the Graph
|
613
|
+
```
|
614
|
+
|
615
|
+
### Manage Vertex Collections
|
616
|
+
|
617
|
+
``` ruby
|
618
|
+
myGraph.vertexCollections # Retrieve all the vertexCollections of the Graph
|
619
|
+
myGraph.addVertexCollection collection: "myCollection" # Add a Vertex Collection to our Graph
|
620
|
+
myGraph.removeVertexCollection collection: "myCollection" # Remove a Vertex Collection to our Graph
|
621
|
+
```
|
622
|
+
|
623
|
+
### Manage Edge Collections
|
624
|
+
|
625
|
+
``` ruby
|
626
|
+
myGraph.edgeCollections # Retrieve all the edgeCollections of the Graph
|
627
|
+
myGraph.addEdgeCollections collection: "myEdgeCollection", from: "myCollectionA", to: "myCollectionB" # Add an Edge Collection to our Graph
|
628
|
+
myGraph.replaceEdgeCollections collection: "myEdgeCollection", from: "myCollectionA", to: "myCollectionB" # Replace an Edge Collection to our Graph
|
629
|
+
myGraph.removeEdgeCollections collection: "myEdgeCollection" # Remove an Edge Collection to our Graph
|
630
|
+
```
|
631
|
+
|
632
|
+
<a name="ArangoVertex"></a><a name="ArangoEdge"></a>
|
633
|
+
## ArangoVertex and ArangoEdge
|
634
|
+
|
635
|
+
Both these two classes inherit the class ArangoDocument.
|
636
|
+
These two classes have been created since ArangoDatabase offers, in connection of the chosen graph, different HTTP requests to manage Vertexes and Edges. We recommend the reader to read carefully the section on [ArangoDocument instances](#ArangoDocument) before to start to use ArangoVertex and ArangoEdge instances.
|
637
|
+
|
638
|
+
### ArangoVertex methods
|
639
|
+
|
640
|
+
ArangoVertex inherit all the methods of ArangoDocument class. The following one works similar to the one of ArangoDocument Class but use different HTTP requests. For this reason the performance could be different.
|
641
|
+
To use ArangoVertex, the Collection of the Vertex needs to be added either to the VertexCollections or to the EdgeCollections of the chosen Graph.
|
642
|
+
|
643
|
+
``` ruby
|
644
|
+
myVertex = ArangoVertex.new key: "newVertex", body: {"value" => 3}, collection: "myCollection", graph: "myGraph", database: "myDatabase" # create a new instance
|
645
|
+
myVertex.create # create a new Document in the Graph
|
646
|
+
myVertex.retrieve # retrieve a Document
|
647
|
+
myVertex.graph # Retrieve Graph of the Document
|
648
|
+
myVertex.replace body: {"value" => 6} # replace the Document
|
649
|
+
myVertex.update body: {"value" => 6} # update the Document
|
650
|
+
myVertex.destroy # delete the Document
|
651
|
+
```
|
652
|
+
|
653
|
+
### ArangoEdge methods
|
654
|
+
|
655
|
+
ArangoEdge inherit all the methods of ArangoDocument class. The following one works similar to the one of ArangoDocument Class but use a different HTTP request. For this reason the performance could be different.
|
656
|
+
To use ArangoEdge, the Collection of the Edge needs to be added to the EdgeCollections of the chosen Graph.
|
657
|
+
|
658
|
+
``` ruby
|
659
|
+
myEdge = ArangoEdge.new key: "newVertex", body: {"value" => 3}, from: myArangoDocument, to: myArangoDocument, collection: "myCollection", graph: "myGraph", database: "myDatabase" # create a new instance
|
660
|
+
myEdge.create # create a new Document of type Edge in the Graph
|
661
|
+
myEdge.retrieve # retrieve a Document
|
662
|
+
myEdge.graph # Retrieve Graph of the Document
|
663
|
+
myEdge.replace body: {"value" => 6} # replace the Document
|
664
|
+
myEdge.update body: {"value" => 6} # update the Document
|
665
|
+
myEdge.destroy # delete the Document
|
666
|
+
```
|
667
|
+
|
668
|
+
<a name="ArangoTraversal"></a>
|
669
|
+
## ArangoTraversal
|
670
|
+
|
671
|
+
ArangoTraversal is used to administrate the traversals.
|
672
|
+
ArangoTraversal needs to know the vertex from where the traversal starts, the direction the traversal is going and either the Graph or the EdgeCollection we want to analize.
|
673
|
+
|
674
|
+
``` ruby
|
675
|
+
myTraversal = ArangoTraversal.new # create new ArangoTraversal
|
676
|
+
myTraversal.vertex = myVertex # define starting Vertex
|
677
|
+
myTraversal.graph = myGraph # define used Graph
|
678
|
+
myTraversal.edgeCollection = myEdgeCollection # define used Edge
|
679
|
+
myTraversal.in # Direction is in
|
680
|
+
myTraversal.out # Direction is out
|
681
|
+
myTraversal.any # Direction is in and out
|
682
|
+
myTraversal.min = 1 # Define how minimum deep we want to go with the traversal
|
683
|
+
myTraversal.max = 3 # Define how maximum deep we want to go with the traversal
|
684
|
+
```
|
685
|
+
|
686
|
+
After the traversal is setup, you can execute it:
|
687
|
+
|
688
|
+
``` ruby
|
689
|
+
myTraversal.execute
|
690
|
+
```
|
691
|
+
|
692
|
+
<a name="arangoaql"></a>
|
693
|
+
## ArangoAQL - ArangoDatabase Query Language
|
694
|
+
|
695
|
+
ArangoAQL is used to manage the ArangoDB query language. To instantiate a query
|
696
|
+
|
697
|
+
``` ruby
|
698
|
+
myQuery = ArangoAQL.new query: "FOR v,e,p IN 1..6 ANY 'Year/2016' GRAPH 'MyGraph' FILTER p.vertices[1].num == 6 && p.vertices[2].num == 22 && p.vertices[6]._key == '424028e5-e429-4885-b50b-007867208c71' RETURN [p.vertices[4].value, p.vertices[5].data]"
|
699
|
+
```
|
700
|
+
|
701
|
+
To execute it use:
|
702
|
+
``` ruby
|
703
|
+
myQuery.execute
|
704
|
+
```
|
705
|
+
|
706
|
+
If the query is too big, you can divide the fetching in pieces, for example:
|
707
|
+
``` ruby
|
708
|
+
myQuery.size = 10
|
709
|
+
myQuery.execute # First 10 documents
|
710
|
+
myQuery.next # Next 10 documents
|
711
|
+
myQuery.next # Next 10 documents
|
712
|
+
```
|
713
|
+
|
714
|
+
### Check property query
|
715
|
+
|
716
|
+
``` ruby
|
717
|
+
myQuery.explain # Show data query
|
718
|
+
myQuery.parse # Parse query
|
719
|
+
myQuery.properties; # Check properties
|
720
|
+
myQuery.current; # Retrieve current Query
|
721
|
+
myQuery.slow; # Retrieve slow Queries
|
722
|
+
myQuery.changeProperties maxSlowQueries: 65 # Change Properties
|
723
|
+
```
|
724
|
+
|
725
|
+
### Delete query
|
726
|
+
|
727
|
+
``` ruby
|
728
|
+
myQuery.stopSlow; # Stop Slow query
|
729
|
+
myQuery.kill; # Kill Query
|
730
|
+
```
|
731
|
+
|
732
|
+
<a name="ArangoUser"></a>
|
733
|
+
## ArangoUser
|
734
|
+
|
735
|
+
ArangoUser manages the users.
|
736
|
+
To initialize an user:
|
737
|
+
|
738
|
+
``` ruby
|
739
|
+
myUser = ArangoUser.new user: "MyUser", password: "password"
|
740
|
+
```
|
741
|
+
|
742
|
+
### User management
|
743
|
+
|
744
|
+
``` ruby
|
745
|
+
myUser.retrieve # Retrieve User
|
746
|
+
myUser["MyDatabase"] # Retrieve database if the user can access it
|
747
|
+
myUser.create # Create a new User
|
748
|
+
myUser.replace active: false # Replace User
|
749
|
+
myUser.update active: false # Update User
|
750
|
+
myUser.destroy # Delete User
|
751
|
+
```
|
752
|
+
|
753
|
+
### Database management
|
754
|
+
|
755
|
+
``` ruby
|
756
|
+
myUser.databases # Check permission Databases
|
757
|
+
myUser.grant database: "MyDatabase" # Grant access to a database
|
758
|
+
myUser.revoke database: "MyDatabase" # Revoke access to a database
|
759
|
+
```
|
760
|
+
|
761
|
+
<a name="ArangoIndex"></a>
|
762
|
+
## ArangoIndex
|
763
|
+
|
764
|
+
ArangoIndex manages the indexes.
|
765
|
+
To initialize an index:
|
766
|
+
|
767
|
+
``` ruby
|
768
|
+
myIndex = ArangoIndex.new fields: "num", unique: false, id: "myIndex"
|
769
|
+
```
|
770
|
+
|
771
|
+
### Index management
|
772
|
+
|
773
|
+
``` ruby
|
774
|
+
myIndex.retrieve # Retrieve Index
|
775
|
+
myIndex.create # Create a new Index
|
776
|
+
ArangoIndex.indexes collection: "MyCollection" # List indexes
|
777
|
+
myIndex.destroy # Delete Index
|
778
|
+
```
|
779
|
+
|
780
|
+
Alternatively, you can create an Index of a Collection directly from its Collection.
|
781
|
+
|
782
|
+
``` ruby
|
783
|
+
myCollection.createIndex unique: false, fields: "num", type: "hash"
|
784
|
+
```
|
785
|
+
|
786
|
+
<a name="ArangoTransaction"></a>
|
787
|
+
## ArangoTransaction
|
788
|
+
|
789
|
+
Transactions are managed by ArangoTransaction. This class has only initialization and execution.
|
790
|
+
|
791
|
+
``` ruby
|
792
|
+
myArangoTransaction = ArangoTransaction.new action: "function(){ var db = require('@arangodb').db; db.MyCollection.save({}); return db.MyCollection.count(); }", write: myCollection # Or read
|
793
|
+
myArangoTransaction.execute # Return the result of the execution
|
794
|
+
```
|
795
|
+
|
796
|
+
<a name="ArangoTask"></a>
|
797
|
+
## ArangoTask
|
798
|
+
|
799
|
+
Tasks are managed by ArangoTask.
|
800
|
+
|
801
|
+
``` ruby
|
802
|
+
myArangoTask = ArangoTask.new id: "mytaskid", name: "MyTaskID", command: "(function(params) { require('@arangodb').print(params); })(params)", params: {"foo" => "bar", "bar" => "foo"}, period: 2 # Initialize a Task Instance that will be alive for 2 seconds
|
803
|
+
myArangoTask.create # Create a new Task
|
804
|
+
ArangoTask.tasks # Retrieve a list of active tasks
|
805
|
+
myArangoTask.retrieve # Retrieve a Task
|
806
|
+
myArangoTask.destroy # Delete a Task
|
807
|
+
```
|
808
|
+
|
809
|
+
<a name="ArangoCache"></a>
|
810
|
+
## ArangoCache
|
811
|
+
|
812
|
+
ArangoCache helps you to manage your request to your Database by creating a cache.
|
813
|
+
|
814
|
+
``` ruby
|
815
|
+
myQuery = ArangoAQL.new query: "FOR v,e,p IN 1..6 ANY 'Year/2016' GRAPH 'MyGraph' FILTER p.vertices[1].num == 6 && p.vertices[2].num == 22 && p.vertices[6]._key == '424028e5-e429-4885-b50b-007867208c71' RETURN [p.vertices[4].value, p.vertices[5].data]"
|
816
|
+
myQuery.execute # Heavy computation
|
817
|
+
ArangoCache.cache data: myQuery # Cache these heavy query
|
818
|
+
ArangoCache.uncache data: myQuery # Retrieve cached ArangoAQL with same query request
|
819
|
+
ArangoCache.clear data: myQuery # Free the cache from these three documents
|
820
|
+
ArangoCache.clear type: "AQL" # Delete cache from AQL requests
|
821
|
+
ArangoCache.clear # Clear completely all the cache
|
822
|
+
```
|
823
|
+
|
824
|
+
Alternatively we can save, retrieve and delete multiple values
|
825
|
+
|
826
|
+
``` ruby
|
827
|
+
myQuery = ArangoAQL.new query: "FOR v,e,p IN 1..6 ANY 'Year/2016' GRAPH 'MyGraph' FILTER p.vertices[1].num == 6 && p.vertices[2].num == 22 && p.vertices[6]._key == '424028e5-e429-4885-b50b-007867208c71' RETURN [p.vertices[4].value, p.vertices[5].data]"
|
828
|
+
myQuery2 = ArangoAQL.new query: "FOR u IN Hour FILTER u._key == "2016-10-04T23" RETURN u"
|
829
|
+
myQuery.execute # Heavy computation
|
830
|
+
myQuery2.execute
|
831
|
+
ArangoCache.cache data: [myQuery, myQuery2] # Cache these heavy query
|
832
|
+
ArangoCache.uncache data: [myQuery, myQuery2] # Retrieve cached ArangoAQL
|
833
|
+
ArangoCache.clear data: [myQuery, myQuery2] # Free the cache from these request
|
834
|
+
```
|
835
|
+
|
836
|
+
If we need we can save with personalized ID.
|
837
|
+
|
838
|
+
``` ruby
|
839
|
+
ArangoCache.cache id: ["myFirstQuery", "mySecondQuery"] data: [myQuery, myQuery2] # Cache these heavy query
|
840
|
+
ArangoCache.uncache type: "AQL", id: ["myFirstQuery", "mySecondQuery"] # Retrieve cached ArangoAQL
|
841
|
+
ArangoCache.clear type: "AQL", id: ["myFirstQuery", "mySecondQuery"] # Free the cache from these request
|
842
|
+
```
|
843
|
+
|
844
|
+
The type and the quantity that you can save in the cache are the following: Database: 1, Collection: 20, Document: 200, Graph: 1, Vertex: 50, Edge: 100, Index: 20, AQL: 100, User: 50, Task: 20, Traversal: 20, Transaction: 20, Other: 100. For "Other" we mean all the values that are not included in the other categories.
|
845
|
+
|
846
|
+
To modify these limitations you can use the following command:
|
847
|
+
``` ruby
|
848
|
+
ArangoCache.max type: "Document", val: 100 # Change limits Document
|
849
|
+
```
|
850
|
+
NB: If you insert a max value higher than the quantity of elements in the Cache, then the first elements in excess will be removed from the Cache.
|
851
|
+
|
852
|
+
If the limit of the Cache for one type is reached, then the first element cached of that type will be deleted from the Cache.
|
853
|
+
|
854
|
+
<a name="ArangoReplication"></a>
|
855
|
+
## Replication
|
856
|
+
|
857
|
+
Replication is useful to create back up copy of your database or to have a master-slave relationship between two databases.
|
858
|
+
|
859
|
+
Remember: the used database is the one where the data will be written (the slave) and the remote database will be the master one.
|
860
|
+
|
861
|
+
Use with caution since the data in the slave database will be deleted.
|
862
|
+
|
863
|
+
To setup our Slave Server and Master Database use a similar command.
|
864
|
+
|
865
|
+
``` ruby
|
866
|
+
ArangoServer.default_server user: "root", password: "tretretre", server: "172.17.8.101", port: "8529" # Our Slave Server
|
867
|
+
myReplication = ArangoReplication.new endpoint: "tcp://10.10.1.97:8529", username: "root", password: "", database: "year" # Our Master Database
|
868
|
+
```
|
869
|
+
|
870
|
+
Than to do a simple syncronization uses;
|
871
|
+
|
872
|
+
``` ruby
|
873
|
+
myReplication.sync
|
874
|
+
```
|
875
|
+
|
876
|
+
To retrieve some information ArangoRB provides the following methods:
|
877
|
+
|
878
|
+
``` ruby
|
879
|
+
myDatabase = ArangoDatabase.new database: "year"
|
880
|
+
myCollection = myDatabase["MyCollection"]
|
881
|
+
myDatabase.inventory # Fetch Collection data
|
882
|
+
myCollection.dump # Fetch all the data in one class from one tick to another
|
883
|
+
myReplication.logger # Returns the current state of the server's replication logger
|
884
|
+
myReplication.loggerFollow # Returns data from the server's replication log.
|
885
|
+
myReplication.firstTick # Return the first available tick value from the server
|
886
|
+
myReplication.rangeTick # Returns the currently available ranges of tick values for all currently available WAL logfiles.
|
887
|
+
myReplication.serverId # Returns the servers id.
|
888
|
+
```
|
889
|
+
|
890
|
+
### Relation Master-Slave
|
891
|
+
|
892
|
+
To enslave a Server in relation to another Database use the following command:
|
893
|
+
|
894
|
+
``` ruby
|
895
|
+
myReplication.enslave
|
896
|
+
```
|
897
|
+
|
898
|
+
To manage the Configuration of a Master-Slave Replication you can use the following commands:
|
899
|
+
|
900
|
+
``` ruby
|
901
|
+
myReplication.configurationReplication # check the Configuration of the Replication
|
902
|
+
myReplication.stateReplication # check the status of the Replication
|
903
|
+
myReplication.stopReplication # stop the Replication
|
904
|
+
myReplication.modifyReplication # modify the Configuration of the Replication (you can modify only a stopped Replication)
|
905
|
+
myReplication.startReplication # restart the replication
|
906
|
+
```
|