active-orient 0.4 → 0.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.graphs.txt.swp +0 -0
- data/Gemfile +9 -5
- data/Guardfile +12 -4
- data/README.md +70 -281
- data/VERSION +1 -1
- data/active-orient.gemspec +9 -7
- data/bin/active-orient-0.6.gem +0 -0
- data/bin/active-orient-console +97 -0
- data/changelog.md +60 -0
- data/config/boot.rb +70 -17
- data/config/config.yml +10 -0
- data/config/connect.yml +11 -6
- data/examples/books.rb +154 -65
- data/examples/streets.rb +89 -85
- data/graphs.txt +70 -0
- data/lib/active-orient.rb +78 -6
- data/lib/base.rb +266 -168
- data/lib/base_properties.rb +76 -65
- data/lib/class_utils.rb +187 -0
- data/lib/database_utils.rb +99 -0
- data/lib/init.rb +80 -0
- data/lib/java-api.rb +442 -0
- data/lib/jdbc.rb +211 -0
- data/lib/model/custom.rb +29 -0
- data/lib/model/e.rb +6 -0
- data/lib/model/edge.rb +114 -0
- data/lib/model/model.rb +134 -0
- data/lib/model/the_class.rb +657 -0
- data/lib/model/the_record.rb +313 -0
- data/lib/model/vertex.rb +371 -0
- data/lib/orientdb_private.rb +48 -0
- data/lib/other.rb +423 -0
- data/lib/railtie.rb +68 -0
- data/lib/rest/change.rb +150 -0
- data/lib/rest/create.rb +287 -0
- data/lib/rest/delete.rb +150 -0
- data/lib/rest/operations.rb +222 -0
- data/lib/rest/read.rb +189 -0
- data/lib/rest/rest.rb +120 -0
- data/lib/rest_disabled.rb +24 -0
- data/lib/support/conversions.rb +42 -0
- data/lib/support/default_formatter.rb +7 -0
- data/lib/support/errors.rb +41 -0
- data/lib/support/logging.rb +38 -0
- data/lib/support/orient.rb +305 -0
- data/lib/support/orientquery.rb +647 -0
- data/lib/support/query.rb +92 -0
- data/rails.md +154 -0
- data/rails/activeorient.rb +32 -0
- data/rails/config.yml +10 -0
- data/rails/connect.yml +17 -0
- metadata +89 -30
- data/lib/model.rb +0 -461
- data/lib/orient.rb +0 -98
- data/lib/query.rb +0 -88
- data/lib/rest.rb +0 -1036
- data/lib/support.rb +0 -347
- data/test.rb +0 -4
- data/usecase.md +0 -91
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8b57e243fb22b2156f6a2e92aa5955cbafead6da0c5fd65be11ef2483b829f07
|
4
|
+
data.tar.gz: 5c67edc1f5c62713ab363720cf43a7f8371470a75c49df8869f4a91b6cd32494
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00d96784e43d226cd3b66acf2d02e6db57459f79fe70893a328d7fa60d3c5b54c27d76f0f082136ed3bfca267e59fd4337818894c98ec367092f4721f6654966
|
7
|
+
data.tar.gz: fbb32f47ab7dbfaa152dd5a0a2432b9c3039125e36255381e3874b8a04b148113a3b23dadf7e1ae22a09384b1144ad7f873aaf0413c8c9094142a921dcb64945
|
data/.gitignore
CHANGED
data/.graphs.txt.swp
ADDED
Binary file
|
data/Gemfile
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
gemspec
|
3
|
-
gem '
|
4
|
-
gem '
|
5
|
-
gem '
|
6
|
-
gem '
|
3
|
+
#gem 'rest-client' , :git => 'https://github.com/rest-client/rest-client.git'
|
4
|
+
#gem 'orientdb' , :path => '/home/topo/orientdb-jruby' , :platforms => :jruby
|
5
|
+
gem 'sdoc', git: 'https://github.com/zzak/sdoc'
|
6
|
+
#gem 'orientdb' , :git => 'git://github.com/topofocus/orientdb-jruby.git', :branch => '2.1.2', :platforms => :jruby
|
7
7
|
group :development, :test do
|
8
|
+
gem "awesome_print"
|
8
9
|
gem "rspec"
|
10
|
+
gem 'rspec-legacy_formatters'
|
9
11
|
gem 'rspec-its'
|
12
|
+
gem 'rspec-given'
|
10
13
|
gem 'rspec-collection_matchers'
|
11
14
|
gem 'rspec-context-private'
|
12
|
-
gem 'guard'
|
15
|
+
# gem 'guard-jruby-rspec', :platforms => :jruby, :git => 'git://github.com/jkutner/guard-jruby-rspec.git'
|
16
|
+
gem 'guard'#, :platforms => :ruby
|
13
17
|
gem 'guard-rspec'
|
14
18
|
## gem 'database_cleaner'
|
15
19
|
gem 'rb-inotify'
|
data/Guardfile
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# A sample Guardfile
|
2
2
|
# More info at https://github.com/guard/guard#readme
|
3
|
-
|
4
|
-
guard :rspec, cmd: "bundle exec rspec" do
|
3
|
+
def fire
|
5
4
|
require "ostruct"
|
6
5
|
|
7
6
|
# Generic Ruby apps
|
@@ -12,10 +11,19 @@ guard :rspec, cmd: "bundle exec rspec" do
|
|
12
11
|
|
13
12
|
|
14
13
|
watch(%r{^spec/.+_spec\.rb$})
|
15
|
-
watch(%r{^spec/usecase/(.+)
|
14
|
+
# watch(%r{^spec/usecase/(.+)\.rb$})
|
16
15
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
16
|
+
# watch(%r{^examples/time_graph/spec/(.+)_spec\.rb$})
|
17
|
+
watch('examples/time_graph/spec/create_time_spec.rb')
|
17
18
|
watch('spec/spec_helper.rb') { "spec" }
|
18
19
|
|
19
|
-
watch(%r{^spec/support/(.+)\.rb$})
|
20
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
20
21
|
end
|
21
22
|
|
23
|
+
|
24
|
+
interactor :simple
|
25
|
+
if RUBY_PLATFORM == 'java'
|
26
|
+
guard( 'jruby-rspec') {fire} #', :spec_paths => ["spec"]
|
27
|
+
else
|
28
|
+
guard( :rspec, cmd: "bundle exec rspec") { fire }
|
29
|
+
end
|
data/README.md
CHANGED
@@ -1,325 +1,114 @@
|
|
1
1
|
# ActiveOrient
|
2
|
-
Use OrientDB to persistently store
|
3
|
-
|
2
|
+
Use OrientDB to persistently store Ruby-Objects and use database queries to manage even very large datasets.
|
3
|
+
**OrientDB Version 3 is required**, OrientDB 3.1 is supported
|
4
4
|
|
5
|
-
|
5
|
+
---
|
6
|
+
**Status**
|
6
7
|
|
8
|
+
* Preparing for a gem release in Dec. 2020
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
+
* Recent updates: concurrent database queries, multiple model-dirs, match-statements
|
11
|
+
* Finally working on the TestSuite
|
12
|
+
---
|
13
|
+
### Quick Start
|
10
14
|
|
11
|
-
|
15
|
+
You need a ruby 2.6 / 2.7 Installation and a working OrientDB-Instance (Version 3.0.17 or above).
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
|
17
|
+
- clone the project,
|
18
|
+
- run bundle install ; bundle update,
|
19
|
+
- update config/connect.yml,
|
20
|
+
- create the documentation:
|
21
|
+
```
|
22
|
+
sdoc . -w2 -x spec -x example
|
23
|
+
```
|
24
|
+
and point the browser to ~/active-orient/doc/index.htm
|
25
|
+
|
26
|
+
- read the [Wiki](./../../wiki/Initialisation)
|
27
|
+
- and start an irb-session by calling
|
16
28
|
```
|
17
|
-
|
18
|
-
|
19
|
-
Assuming, the server is located on localhost, we just define »default-server«
|
20
|
-
```ruby
|
21
|
-
ActiveOrient::OrientDB.default_server= { user: 'your user', password: 'your password' }
|
22
|
-
|
23
|
-
|
24
|
-
r = ActiveOrient::OrientDB.new database: 'First'
|
25
|
-
=> I, [2015-08-18T09:49:18.858758 #88831] INFO -- OrientDB#Connect: Connected to database First
|
26
|
-
=> #<ActiveOrient::OrientDB:0x000000048d0488 @res=#<RestClient::Resource:0x00000004927288
|
27
|
-
@url="http://localhost:2480", @block=nil,
|
28
|
-
@options={:user=>"xx", :password=>"***"}>, @database="First", @classes=[]>
|
29
|
+
cd bin
|
30
|
+
./active-orient-console t)est # or d)develpoment, p)roduction environment as defined in config/connect.ym
|
29
31
|
```
|
30
32
|
|
31
|
-
|
33
|
+
### Philosophy
|
32
34
|
|
33
35
|
|
34
|
-
|
36
|
+
OrientDB is a Multi-Model-Database. It shares the concept of Inheritance with OO-Languages, like Ruby.
|
37
|
+
|
38
|
+
Upon initialization `ActiveOrient` reads the complete structure of the database, creates corresponding ruby-classes (including inheritance) and then loads user defined methods from the `Model Directory`. A separate schema definition is not neccesary.
|
35
39
|
|
36
|
-
|
37
|
-
M = r.open_class 'classname' #
|
38
|
-
M = r.create_class 'classname' # creates or opens a basic document-class
|
39
|
-
M = r.create_vertex_class 'classname' # creates or opens a vertex-class
|
40
|
-
M = r.create_edge_class 'classname' # creates or opens an edge-class, providing bidirectional links between documents
|
40
|
+
`ActiveOrient` queries the OrientDB-Database, provides a cache to speed things up and provides handy methods to simplify the work with OrientDB. Like Active-Record it represents the "M" Part of the MCV-Design-Pattern. There is explicit Namespace support. Its philosophie resembles the [Hanami Project](https://github.com/hanami/hanami).
|
41
41
|
|
42
|
-
r.delete_class M # universal removal-of-the-class-method
|
43
|
-
```
|
44
42
|
|
45
43
|
|
46
|
-
»M« is the ActiveOrient::Model-Class itself, a constant pointing to the class-definition of the ruby-class.
|
47
|
-
Its a shortcut for »ActiveOrient::Model::{Classname} and is reused if defined elsewhere.
|
48
44
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
45
|
+
#### CRUD
|
46
|
+
The CRUD-Process (create, read = query, update and remove) is performed as
|
47
|
+
```ruby
|
48
|
+
# create the class
|
49
|
+
V.create_class :m # V is the base »vertex» class. M is a vertex-class.
|
50
|
+
# create a record
|
51
|
+
M.create name: 'Hugo', age: 46, interests: [ 'swimming', 'biking', 'reading' ]
|
52
|
+
# query the database
|
53
|
+
hugo = M.where( name: 'Hugo' ).first
|
54
|
+
# update the dataset
|
55
|
+
hugo.update father: M.create( name: "Volker", age: 76 ) # we create an internal link
|
56
|
+
hugo.father.name # --> volker
|
57
|
+
# change array elements
|
58
|
+
hugo.interests << "dancing" # --> [ 'swimming', 'biking', 'reading', 'dancing' ]
|
59
|
+
M.remove hugo
|
60
|
+
M.delete_class # removes the class from OrientDB and deletes the ruby-object-definition
|
64
61
|
```
|
62
|
+
|
65
63
|
|
66
64
|
#### Active Model interface
|
67
|
-
|
68
|
-
Every OrientDB-Database-Class is mirrord as Ruby-Class. The Class itself is defined by
|
69
|
-
```ruby
|
70
|
-
M = r.create_class 'classname'
|
71
|
-
M = r.create_class { superclass_name: 'classname' }
|
72
|
-
Vertex = r.create_vertex_class 'classname'
|
73
|
-
Edge = r.create_edge_class 'classname'
|
74
|
-
```
|
75
|
-
and is of TYPE ActiveOrient::Model::{classname}
|
76
65
|
|
77
|
-
As for ActiveRecord-Tables, the
|
66
|
+
As for ActiveRecord-Tables, the Model-class itself provides methods to inspect and filter datasets form the database.
|
78
67
|
|
79
68
|
```ruby
|
80
69
|
M.all
|
81
70
|
M.first
|
82
71
|
M.last
|
83
|
-
|
84
|
-
|
85
|
-
```ruby
|
86
|
-
M.where town: 'Berlin'
|
87
|
-
```
|
88
|
-
performs a query on the class and returns the result as Array
|
72
|
+
M.where town: 'Berlin'
|
73
|
+
M.like "name = G*"
|
89
74
|
|
90
|
-
```ruby
|
91
75
|
M.count where: { town: 'Berlin' }
|
92
76
|
```
|
93
|
-
gets the number of datasets
|
94
|
-
SQL-Query in Orientdb can be provided to the count, where, first and last-method.
|
95
|
-
|
96
|
-
A »normal« Query is submitted via
|
97
|
-
```ruby
|
98
|
-
M.get_documents projection: { projection-parameter }
|
99
|
-
distinct: { some parameters }
|
100
|
-
where: { where-parameter }
|
101
|
-
order: { sorting-parameters }
|
102
|
-
group_by: { one grouping-parameter}
|
103
|
-
unwind:
|
104
|
-
skip:
|
105
|
-
limit:
|
106
|
-
|
107
|
-
# or
|
108
|
-
query = OrientSupport::OrientQuery.new {paramter}
|
109
|
-
M.get_documents query: query
|
110
|
-
|
111
|
-
```
|
112
|
-
|
113
|
-
Basic graph-support:
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
```ruby
|
118
|
-
vertex_1 = Vertex.create color: "blue"
|
119
|
-
vertex_2 = Vertex.create flower: "rose"
|
120
|
-
Edge.create_edge attributes: { :birthday => Date.today }, from: vertex_1, to: vertex_2
|
121
|
-
```
|
122
|
-
connects the vertices and assigns the attributes to the edge
|
123
|
-
|
124
|
-
|
125
|
-
#### Links
|
126
|
-
|
127
|
-
A record in a database-class is defined by a »rid«. Every Model-Object comes with a handy »link«-method.
|
128
|
-
|
129
|
-
In OrientDB links are used to realise unidirectional 1:1 and 1:n relationships.
|
130
|
-
|
131
|
-
ActiveOrient autoloads Model-objects when they are accessed. As a consequence,
|
132
|
-
if an Object is stored in Cluster 30 and id 2, then "#30:2" fully qualifies the ActiveOrient::Model object.
|
133
|
-
|
134
|
-
```ruby
|
135
|
-
TestLinks = r.create_class 'Test_link_class'
|
136
|
-
TestBase = r.create_class 'Test_base_class'
|
137
|
-
|
138
|
-
link_document = TestLinks.create att: 'one attribute'
|
139
|
-
base_document = TestBase.create base: 'my_base', single_link: link_document
|
140
|
-
```
|
141
|
-
base_document.single_link just contains the rid. When accessed, the ActiveOrient::Model::Testlinkclass-object is autoloaded and
|
142
|
-
``` ruby
|
143
|
-
base_document.single_link.att
|
144
|
-
```
|
145
|
-
reads the stored content of link_document.
|
146
|
-
|
147
|
-
To store a list of links to other Database-Objects a simple Array is allocated
|
148
|
-
``` ruby
|
149
|
-
# predefined linkmap-properties
|
150
|
-
base_document = TestBase.create links: []
|
151
|
-
( 0 .. 20 ).each{ |y| base_document.links << TestLinks.create nr: y }
|
152
|
-
end
|
153
|
-
#or in schemaless-mode
|
154
|
-
base_document = TestBase.create links: (0..20).map{|y| TestLinks.create nr: y }
|
155
|
-
|
156
|
-
|
157
|
-
```
|
158
|
-
base_document.links behaves like a ruby-array.
|
159
|
-
|
160
|
-
If you got an undirectional graph
|
161
|
-
|
162
|
-
a --> b ---> c --> d
|
163
|
-
|
164
|
-
the graphelements can be explored by joining the objects ( a.b.c.d ), or (a.b[5].c[9].d )
|
165
|
-
|
166
|
-
#### Edges
|
77
|
+
»count« gets the number of datasets fulfilling the search-criteria. Any parameter defining a valid SQL-Query in Orientdb can be provided to the »count«, »where«, »first« and »last«-method.
|
167
78
|
|
168
|
-
|
79
|
+
A »normal« Query is submitted via
|
169
80
|
```ruby
|
170
|
-
|
171
|
-
|
81
|
+
M.query.projection( projection-parameter)
|
82
|
+
.distinct( some parameters)
|
83
|
+
.where( where-parameter)
|
84
|
+
.order( sorting-parameters )
|
85
|
+
.group_by( one grouping-parameter )
|
86
|
+
(...)
|
87
|
+
.execute
|
172
88
|
|
173
|
-
start = Vertex.create something: 'nice'
|
174
|
-
the_end = Vertex.create something: 'not_nice'
|
175
|
-
the_edge = Edge.create_edge attributes: { transform_to: 'very bad' },
|
176
|
-
from: start,
|
177
|
-
to: the_end
|
178
|
-
|
179
|
-
(...)
|
180
|
-
the_edge.delete
|
181
89
|
```
|
182
90
|
|
183
|
-
|
184
|
-
The Edges are accessed by their names (downcase).
|
185
|
-
|
186
|
-
```ruby
|
187
|
-
start.e1[0]
|
188
|
-
--> #<ActiveOrient::Model::E1:0x000000041e4e30
|
189
|
-
@metadata={"type"=>"d", "class"=>"E1", "version"=>60, "fieldTypes"=>"out=x,in=x",
|
190
|
-
"cluster"=>16, "record"=>43},
|
191
|
-
@attributes={"out"=>"#31:23", "in"=>"#31:15", "transform_to"=>"very bad" }>
|
192
|
-
```
|
193
|
-
The Attributes "in" and "out" can be used to move across the graph
|
194
|
-
```ruby
|
195
|
-
start.e1[0].out.something
|
196
|
-
---> "not_nice
|
197
|
-
start.e1[0].in.something
|
198
|
-
---> "nice
|
199
|
-
```
|
200
|
-
#### Queries
|
201
|
-
Contrary to traditional SQL-based Databases OrientDB handles subqueries very efficient.
|
202
|
-
In addition, OrientDB supports precompiled statements (let-Blocks).
|
203
|
-
|
204
|
-
ActiveOrient is equipped with a simple QueryGenerator: ActiveSupport::OrientQuery.
|
205
|
-
It works in two modi: a comprehensive and a subsequent one
|
206
|
-
```ruby
|
207
|
-
|
208
|
-
q = OrientSupport::OrientQuery.new
|
209
|
-
q.from = Vertex
|
210
|
-
q.where << a: 2
|
211
|
-
q.where << 'b > 3 '
|
212
|
-
q.distinct = :profession
|
213
|
-
q.order = { :name => :asc }
|
214
|
-
|
215
|
-
```
|
216
|
-
is equivalent to
|
217
|
-
```ruby
|
218
|
-
q = OrientSupport::OrientQuery.new from: Vertex ,
|
219
|
-
where: [{ a: 2 }, 'b > 3 '],
|
220
|
-
distinct: :profession,
|
221
|
-
order: { :name => :asc }
|
222
|
-
q.to_s
|
223
|
-
=> select distinct( profession ) from Vertex where a = 2 and b > 3 order by name asc
|
224
|
-
```
|
225
|
-
Both modes can be mixed.
|
226
|
-
|
227
|
-
If subqueries are nessesary, they can be introduced as OrientSupport::OrientQuery or as »let-block«.
|
228
|
-
```ruby
|
229
|
-
q = OrientSupport::OrientQuery.new from: 'ModelQuery'
|
230
|
-
q.let << "$city = adress.city"
|
231
|
-
q.where = "$city.country.name = 'Italy' OR $city.country.name = 'France'"
|
232
|
-
q.to_s
|
233
|
-
=> select from ModelQuery let $city = adress.city where $city.country.name = 'Italy' OR $city.country.name = 'France'
|
234
|
-
```
|
235
|
-
or
|
91
|
+
To update several records, a class-method »update« is provided.
|
236
92
|
```ruby
|
237
|
-
|
238
|
-
|
239
|
-
q.let << { b: OrientSupport::OrientQuery.new( from: '#5:1' ) }
|
240
|
-
q.let << '$c= UNIONALL($a,$b) '
|
241
|
-
q.projection << 'expand( $c )'
|
242
|
-
q.to_s
|
243
|
-
=> select expand( $c ) let $a = ( select from #5:0 ), $b = ( select from #5:1 ), $c= UNIONALL($a,$b)
|
93
|
+
M.update connected: false # add a property »connected» to each record
|
94
|
+
M.update set:{ connected: true }, where: "symbol containsText 'S'"
|
244
95
|
```
|
245
96
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
#### Execute SQL-Commands
|
250
|
-
Sql-commands can be executed as batch
|
251
|
-
|
252
|
-
The ActiveOrient::Query-Class provides a Query-Stack and an Records-Array which keeps the results.
|
253
|
-
The ActiveOrient::Query-Class acts as Parent-Class for aggregated Records (without a @rid), which are ActiveOrient::Model::Myquery Objects. If a Query returns a database-record, the correct ActiveOrient::Model-Class is instantiated.
|
97
|
+
Graph-support:
|
254
98
|
|
255
99
|
```ruby
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
ach.queries << 'create class Stocks extends Contracts'
|
262
|
-
ach.queries << 'create class Futures extends Contracts'
|
263
|
-
result = ach.execute_queries transaction: false
|
264
|
-
|
265
|
-
|
266
|
-
|
100
|
+
V.create_class :the_vertex
|
101
|
+
E.create_class :the_edge
|
102
|
+
vertex_1 = TheVertex.create color: "blue"
|
103
|
+
vertex_2 = TheVertex.create flower: "rose"
|
104
|
+
vertex_1.assign via: TheEdge, vertex: vertex_2, attributes: {:birthday => Date.today }
|
267
105
|
```
|
268
|
-
|
269
|
-
|
270
|
-
This feature can be used as a substitute for simple functions
|
106
|
+
It connects the vertices and assigns the attributes to the edge.
|
271
107
|
|
272
|
-
|
273
|
-
roq = ActiveOrient::Query.new
|
274
|
-
roq.queries =["select name, categories.subcategories.contracts from Industries where name containstext …'ial'"]
|
275
|
-
roq.execute_queries.each{|x| puts x.name, x.categories.inspect }
|
276
|
-
--> Basic Materials [["#21:1"]]
|
277
|
-
--> Financial [["#21:2"]]
|
278
|
-
--> Industrial [["#23:0", "#23:1"]]
|
279
|
-
```
|
108
|
+
To query a graph, SQL-like-Queries and Match-statements can be used (details in the [wiki](https://github.com/topofocus/active-orient/wiki)).
|
280
109
|
|
281
|
-
|
282
|
-
( http://orientdb.com/docs/2.0/orientdb.wiki/SQL-batch.html )
|
283
|
-
This is supported simply by using a Array as Argument for ActiveOrient::Query.queries
|
110
|
+
#### Other Documents
|
284
111
|
|
285
|
-
|
286
|
-
```ruby
|
287
|
-
ach = ActiveOrient::Query.new
|
288
|
-
ach.queries << [ "select expand( contracts ) from Openinterest"
|
289
|
-
"let con = select expand( contracts ) from Openinterest; ",
|
290
|
-
"...", ... ]
|
291
|
-
result = ach.execute_queries
|
292
|
-
```
|
112
|
+
- [Rails 5-Integration](./rails.md)
|
293
113
|
|
294
|
-
The contract-documents are accessible with
|
295
|
-
```ruby
|
296
|
-
r.get_document '21:1'
|
297
|
-
--><Stocks: con_id: 77680640 currency: EUR details: #18:1 exchange: SMART local_symbol: BAS
|
298
|
-
primary_exchange: IBIS subcategory: #14:1 symbol: BAS>
|
299
|
-
```
|
300
|
-
or
|
301
|
-
```ruby
|
302
|
-
my_query = ActiveOrient::Query.new
|
303
|
-
['Contracts', 'Industries', 'Categories', 'Subcategories'].each do |table|
|
304
|
-
my_query.queries = [ "select count(*) from #{table}"]
|
305
|
-
|
306
|
-
count = my_query.execute_queries
|
307
|
-
# count=> [#<ActiveOrient::Model::Myquery:0x00000003b317c8
|
308
|
-
# @metadata={"type"=>"d", "class"=>nil, "version"=>0, "fieldTypes"=>"count=l"},
|
309
|
-
# @attributes={"count"=>4 } ] --> an Array with one Element, therefor count.pop
|
310
|
-
puts "Table #{table} \t #{count.pop.count} Datasets "
|
311
|
-
end
|
312
|
-
-->Table Contracts 56 Datasets
|
313
|
-
-->Table Industries 8 Datasets
|
314
|
-
-->Table Categories 22 Datasets
|
315
|
-
-->Table Subcategories 35 Datasets
|
316
|
-
|
317
|
-
```
|
318
|
-
|
319
|
-
Note that the fetched Object is of type »Stocks« (ActiveOrient::Model::Stocks).
|
320
114
|
|
321
|
-
The ActiveOrient-API documentation can be found here: https://github.com/orientechnologies/orientdb-docs/wiki/OrientDB-ActiveOrient
|
322
|
-
and the ActiveModel-documentation is here: http://www.rubydoc.info/gems/activemodel
|
323
|
-
|
324
|
-
|
325
|
-
|