arcadedb 0.3.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -1
- data/Gemfile +2 -7
- data/Gemfile.lock +59 -75
- data/README.md +105 -30
- data/arcade.yml +4 -8
- data/arcadedb.gemspec +3 -6
- data/bin/console +19 -19
- data/iruby/.ipynb_checkpoints/01-start-and-end-of-datarows-checkpoint.ipynb +258 -0
- data/iruby/01-start-and-end-of-datarows.ipynb +203 -0
- data/iruby/db-console.rb +73 -0
- data/lib/arcade/api/operations.rb +56 -144
- data/lib/arcade/api/primitives.rb +126 -0
- data/lib/arcade/base.rb +88 -56
- data/lib/{config.rb → arcade/config.rb} +14 -13
- data/lib/arcade/database.rb +110 -131
- data/lib/arcade/errors.rb +8 -0
- data/lib/arcade/match.rb +162 -0
- data/lib/{query.rb → arcade/query.rb} +36 -20
- data/lib/{support → arcade/support}/conversions.rb +2 -1
- data/lib/{support → arcade/support}/model.rb +25 -17
- data/lib/arcade/version.rb +1 -1
- data/lib/arcade.rb +15 -18
- data/lib/model/document.rb +22 -0
- data/lib/model/edge.rb +12 -0
- data/lib/model/vertex.rb +70 -51
- metadata +31 -14
- data/lib/arcade/api/version.rb +0 -5
- data/lib/match.rb +0 -216
- /data/lib/{init.rb → arcade/init.rb} +0 -0
- /data/lib/{support → arcade/support}/class.rb +0 -0
- /data/lib/{support → arcade/support}/object.rb +0 -0
- /data/lib/{support → arcade/support}/sql.rb +0 -0
- /data/lib/{support → arcade/support}/string.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d7f1f29472b0fb31734654c9456ec5bdfb31cd42fd46b658139ac840691c6f6
|
4
|
+
data.tar.gz: 4c1c95707c8e2c528654f2a7509b1b6943ef9615fe203c81cd421d52636dcac7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f54746f04760ebfbc8c1588e66fb0bb52e820eef83df564e3563e37219835ff86c93e5b3d2e2a7617452218938c30a5aabff099361d0fd829890e2ac83411fc8
|
7
|
+
data.tar.gz: 0f8bf3623302c5204ca56552fb41694bfd506c493dc72463b8000e66c82aacddb7f42188f41508c84e9fc5bf93fa78e42e4235ed904982b97d38a4a5c8d4ff40
|
data/CHANGELOG.md
CHANGED
@@ -12,4 +12,22 @@ All notable changes to this project will be documented in this file.
|
|
12
12
|
- Support for embedded Dokuments and Maps
|
13
13
|
- iruby support
|
14
14
|
|
15
|
-
|
15
|
+
## 0.4.0 - 2023.10.28
|
16
|
+
- completely remove pg-stuff
|
17
|
+
- substitute typhoreous with HTTPX
|
18
|
+
|
19
|
+
## 0.4.1 - 2023.10.31
|
20
|
+
- redesign of transactions.
|
21
|
+
- Type.execute performs non idempotent queries in a (nested) transaction
|
22
|
+
- Type.transmit performs non idempotent queries
|
23
|
+
- Type.query performs idempotent queries
|
24
|
+
- Type.create returns a rid
|
25
|
+
- Type.insert returns a type-object
|
26
|
+
- Vertex.nodes supports conditions on edges
|
27
|
+
- Vertex.in, Vertex.out Vertex.inE, Vertex.outE support depth as second parameter
|
28
|
+
- IRuby-Support. Formatted output for Base-Objects
|
29
|
+
|
30
|
+
## 0.5.0 - 2023-12-12
|
31
|
+
- Arcade::Match simple match-statement generator
|
32
|
+
- return to Arcade::QueryError messages instead of HTTPX::HTTPError
|
33
|
+
- The ProjectRoot Const is used to read configuration files (Changed from Arcade::ProjectRoot)
|
data/Gemfile
CHANGED
@@ -5,17 +5,12 @@ source "https://rubygems.org"
|
|
5
5
|
#git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
6
6
|
gemspec
|
7
7
|
gem 'sdoc'
|
8
|
-
gem 'dry-configurable'
|
9
|
-
gem 'pry'
|
10
|
-
#gem 'sequel'
|
11
|
-
|
12
|
-
#gem 'mini_sql' #, path: '../mini_sql/'
|
13
8
|
group :development, :test do
|
14
9
|
gem "awesome_print"
|
15
10
|
gem 'pastel'
|
16
11
|
gem 'zeitwerk'
|
17
12
|
gem 'terminal-table'
|
18
|
-
|
13
|
+
# gem 'rubocop'
|
19
14
|
gem "rspec"
|
20
15
|
gem 'rspec-legacy_formatters'
|
21
16
|
gem 'rspec-its'
|
@@ -26,5 +21,5 @@ group :development, :test do
|
|
26
21
|
gem 'guard'#, :platforms => :ruby
|
27
22
|
gem 'guard-rspec'
|
28
23
|
gem 'rb-inotify'
|
29
|
-
gem 'pry'
|
24
|
+
# gem 'pry'
|
30
25
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,56 +1,56 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
arcadedb (0.
|
4
|
+
arcadedb (0.4.1)
|
5
|
+
dry-configurable
|
5
6
|
dry-core
|
6
7
|
dry-schema
|
7
8
|
dry-struct
|
8
|
-
|
9
|
+
httpx
|
9
10
|
|
10
11
|
GEM
|
11
12
|
remote: https://rubygems.org/
|
12
13
|
specs:
|
13
|
-
ast (2.4.2)
|
14
14
|
awesome_print (1.9.2)
|
15
15
|
coderay (1.1.3)
|
16
|
-
concurrent-ruby (1.
|
16
|
+
concurrent-ruby (1.2.2)
|
17
17
|
diff-lcs (1.5.0)
|
18
|
-
dry-configurable (
|
18
|
+
dry-configurable (1.1.0)
|
19
|
+
dry-core (~> 1.0, < 2)
|
20
|
+
zeitwerk (~> 2.6)
|
21
|
+
dry-core (1.0.1)
|
19
22
|
concurrent-ruby (~> 1.0)
|
20
|
-
|
21
|
-
dry-
|
22
|
-
concurrent-ruby (~> 1.0)
|
23
|
-
dry-core (0.7.1)
|
24
|
-
concurrent-ruby (~> 1.0)
|
25
|
-
dry-inflector (0.3.0)
|
23
|
+
zeitwerk (~> 2.6)
|
24
|
+
dry-inflector (1.0.0)
|
26
25
|
dry-initializer (3.1.1)
|
27
|
-
dry-logic (1.
|
26
|
+
dry-logic (1.5.0)
|
28
27
|
concurrent-ruby (~> 1.0)
|
29
|
-
dry-core (~> 0
|
30
|
-
|
28
|
+
dry-core (~> 1.0, < 2)
|
29
|
+
zeitwerk (~> 2.6)
|
30
|
+
dry-schema (1.13.3)
|
31
31
|
concurrent-ruby (~> 1.0)
|
32
|
-
dry-configurable (~> 0
|
33
|
-
dry-core (~> 0
|
32
|
+
dry-configurable (~> 1.0, >= 1.0.1)
|
33
|
+
dry-core (~> 1.0, < 2)
|
34
34
|
dry-initializer (~> 3.0)
|
35
|
-
dry-logic (
|
36
|
-
dry-types (
|
37
|
-
|
38
|
-
|
39
|
-
dry-
|
35
|
+
dry-logic (>= 1.4, < 2)
|
36
|
+
dry-types (>= 1.7, < 2)
|
37
|
+
zeitwerk (~> 2.6)
|
38
|
+
dry-struct (1.6.0)
|
39
|
+
dry-core (~> 1.0, < 2)
|
40
|
+
dry-types (>= 1.7, < 2)
|
40
41
|
ice_nine (~> 0.11)
|
41
|
-
|
42
|
+
zeitwerk (~> 2.6)
|
43
|
+
dry-types (1.7.1)
|
42
44
|
concurrent-ruby (~> 1.0)
|
43
|
-
dry-
|
44
|
-
dry-
|
45
|
-
dry-
|
46
|
-
|
47
|
-
|
48
|
-
ffi (>= 1.15.0)
|
49
|
-
ffi (1.15.5)
|
45
|
+
dry-core (~> 1.0)
|
46
|
+
dry-inflector (~> 1.0)
|
47
|
+
dry-logic (~> 1.4)
|
48
|
+
zeitwerk (~> 2.6)
|
49
|
+
ffi (1.16.3)
|
50
50
|
formatador (1.1.0)
|
51
51
|
given_core (3.8.2)
|
52
52
|
sorcerer (>= 0.3.7)
|
53
|
-
guard (2.18.
|
53
|
+
guard (2.18.1)
|
54
54
|
formatador (>= 0.2.4)
|
55
55
|
listen (>= 2.7, < 4.0)
|
56
56
|
lumberjack (>= 1.0.12, < 2.0)
|
@@ -64,44 +64,44 @@ GEM
|
|
64
64
|
guard (~> 2.1)
|
65
65
|
guard-compat (~> 1.1)
|
66
66
|
rspec (>= 2.99.0, < 4.0)
|
67
|
+
http-2-next (1.0.1)
|
68
|
+
httpx (1.1.0)
|
69
|
+
http-2-next (>= 1.0.1)
|
67
70
|
ice_nine (0.11.2)
|
68
|
-
listen (3.
|
71
|
+
listen (3.8.0)
|
69
72
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
70
73
|
rb-inotify (~> 0.9, >= 0.9.10)
|
71
|
-
lumberjack (1.2.
|
74
|
+
lumberjack (1.2.9)
|
72
75
|
method_source (1.0.0)
|
73
76
|
nenv (0.3.0)
|
74
77
|
notiffany (0.1.3)
|
75
78
|
nenv (~> 0.1)
|
76
79
|
shellany (~> 0.0)
|
77
|
-
parallel (1.22.1)
|
78
|
-
parser (3.1.2.0)
|
79
|
-
ast (~> 2.4.1)
|
80
80
|
pastel (0.8.0)
|
81
81
|
tty-color (~> 0.5)
|
82
|
-
pry (0.14.
|
82
|
+
pry (0.14.2)
|
83
83
|
coderay (~> 1.1)
|
84
84
|
method_source (~> 1.0)
|
85
|
-
|
85
|
+
psych (5.1.1.1)
|
86
|
+
stringio
|
86
87
|
rake (13.0.6)
|
87
|
-
rb-fsevent (0.11.
|
88
|
+
rb-fsevent (0.11.2)
|
88
89
|
rb-inotify (0.10.1)
|
89
90
|
ffi (~> 1.0)
|
90
|
-
rdoc (6.
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
rspec-
|
95
|
-
rspec-
|
96
|
-
|
97
|
-
rspec-collection_matchers (1.2.0)
|
91
|
+
rdoc (6.5.0)
|
92
|
+
psych (>= 4.0.0)
|
93
|
+
rspec (3.12.0)
|
94
|
+
rspec-core (~> 3.12.0)
|
95
|
+
rspec-expectations (~> 3.12.0)
|
96
|
+
rspec-mocks (~> 3.12.0)
|
97
|
+
rspec-collection_matchers (1.2.1)
|
98
98
|
rspec-expectations (>= 2.99.0.beta1)
|
99
99
|
rspec-context-private (0.0.1)
|
100
|
-
rspec-core (3.
|
101
|
-
rspec-support (~> 3.
|
102
|
-
rspec-expectations (3.
|
100
|
+
rspec-core (3.12.2)
|
101
|
+
rspec-support (~> 3.12.0)
|
102
|
+
rspec-expectations (3.12.3)
|
103
103
|
diff-lcs (>= 1.2.0, < 2.0)
|
104
|
-
rspec-support (~> 3.
|
104
|
+
rspec-support (~> 3.12.0)
|
105
105
|
rspec-given (3.8.2)
|
106
106
|
given_core (= 3.8.2)
|
107
107
|
rspec (>= 2.14.0)
|
@@ -110,34 +110,21 @@ GEM
|
|
110
110
|
rspec-expectations (>= 3.0.0)
|
111
111
|
rspec-legacy_formatters (1.0.2)
|
112
112
|
rspec (~> 3.0)
|
113
|
-
rspec-mocks (3.
|
113
|
+
rspec-mocks (3.12.6)
|
114
114
|
diff-lcs (>= 1.2.0, < 2.0)
|
115
|
-
rspec-support (~> 3.
|
116
|
-
rspec-support (3.
|
117
|
-
|
118
|
-
|
119
|
-
parser (>= 3.1.0.0)
|
120
|
-
rainbow (>= 2.2.2, < 4.0)
|
121
|
-
regexp_parser (>= 1.8, < 3.0)
|
122
|
-
rexml (>= 3.2.5, < 4.0)
|
123
|
-
rubocop-ast (>= 1.17.0, < 2.0)
|
124
|
-
ruby-progressbar (~> 1.7)
|
125
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
126
|
-
rubocop-ast (1.18.0)
|
127
|
-
parser (>= 3.1.1.0)
|
128
|
-
ruby-progressbar (1.11.0)
|
129
|
-
sdoc (2.3.1)
|
130
|
-
rdoc (>= 5.0, < 6.4.0)
|
115
|
+
rspec-support (~> 3.12.0)
|
116
|
+
rspec-support (3.12.1)
|
117
|
+
sdoc (2.6.1)
|
118
|
+
rdoc (>= 5.0)
|
131
119
|
shellany (0.0.1)
|
132
120
|
sorcerer (2.0.1)
|
121
|
+
stringio (3.0.8)
|
133
122
|
terminal-table (3.0.2)
|
134
123
|
unicode-display_width (>= 1.1.1, < 3)
|
135
|
-
thor (1.
|
124
|
+
thor (1.3.0)
|
136
125
|
tty-color (0.6.0)
|
137
|
-
|
138
|
-
|
139
|
-
unicode-display_width (2.1.0)
|
140
|
-
zeitwerk (2.5.4)
|
126
|
+
unicode-display_width (2.5.0)
|
127
|
+
zeitwerk (2.6.12)
|
141
128
|
|
142
129
|
PLATFORMS
|
143
130
|
x86_64-linux
|
@@ -146,11 +133,9 @@ DEPENDENCIES
|
|
146
133
|
arcadedb!
|
147
134
|
awesome_print
|
148
135
|
bundler (~> 2)
|
149
|
-
dry-configurable
|
150
136
|
guard
|
151
137
|
guard-rspec
|
152
138
|
pastel
|
153
|
-
pry
|
154
139
|
rake (~> 13.0)
|
155
140
|
rb-inotify
|
156
141
|
rspec
|
@@ -159,7 +144,6 @@ DEPENDENCIES
|
|
159
144
|
rspec-given
|
160
145
|
rspec-its
|
161
146
|
rspec-legacy_formatters
|
162
|
-
rubocop
|
163
147
|
sdoc
|
164
148
|
terminal-table
|
165
149
|
zeitwerk
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ Ruby Interface to a [Arcade Database](https://arcadedb.com/).
|
|
5
5
|
The program utilizes the HTTP-JSON API to direct database queries to an ArcadeDB server.
|
6
6
|
The server's response is then mapped to an ORM (Object-Relational Mapping) based on DRY::Struct.
|
7
7
|
Each database type is represented by a dedicated Model Class, where complex queries are encapsulated.
|
8
|
-
The program also includes a Query-Preprocessor for constructing custom queries in ruby fashion.
|
8
|
+
The program also includes a Query-Preprocessor and Match-statment generator for constructing custom queries in ruby fashion.
|
9
9
|
|
10
10
|
***ArcadeDB internally uses `Arcade` as primary namespace****
|
11
11
|
|
@@ -13,11 +13,18 @@ The program also includes a Query-Preprocessor for constructing custom queries
|
|
13
13
|
|
14
14
|
A running AracdeDB-Instance. [Quick-Start-Guide](https://docs.arcadedb.com/#Quick-Start-Docker).
|
15
15
|
|
16
|
-
|
16
|
+
## New Project
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
```
|
19
|
+
mkdir project && cd project
|
20
|
+
bundle init
|
21
|
+
bundle add arcadedb
|
22
|
+
bundle add pastel # for console output
|
23
|
+
mkdir model
|
24
|
+
mkdir bin
|
25
|
+
```
|
26
|
+
copy `https://github.com/topofocus/arcadedb/blob/main/bin/console` to the `bin` directory
|
27
|
+
copy `https://github.com/topofocus/arcadedb/blob/main/arcade.yml` to the project root and modify to your needs
|
21
28
|
|
22
29
|
## Console
|
23
30
|
|
@@ -25,9 +32,19 @@ To start an interactive console, a script is provided in the bin-directory.
|
|
25
32
|
```
|
26
33
|
$ cd bin && ./console.rb t ( or "d" or "p" for Test, Development and Production environment)
|
27
34
|
|
28
|
-
**Database definitions (model-files) of the test-suite are included!**
|
35
|
+
**in Test environment Database definitions (model-files) of the test-suite are included!**
|
29
36
|
```
|
30
37
|
|
38
|
+
## Add to a project
|
39
|
+
Just require it in your program:
|
40
|
+
```ruby
|
41
|
+
require "arcade"
|
42
|
+
```
|
43
|
+
## Config
|
44
|
+
|
45
|
+
Add a file `arcade.yml` at the root of your program or in the `config`-dir and provide suitable databases for test, development and production environment.
|
46
|
+
|
47
|
+
|
31
48
|
## Examples & Specs
|
32
49
|
|
33
50
|
The `example` directory contains documented sample files for typical usecases
|
@@ -39,14 +56,13 @@ The `spec`-files in the rspec-test-suite-section are worth reading, too.
|
|
39
56
|
The adapter uses a 3 layer concept.
|
40
57
|
|
41
58
|
Top-Layer : `Arcade::Base`-Model-Objects.
|
42
|
-
|
59
|
+
Similar to ActiveRecord Model Objects but based on [Dry-Struct](https://dry-rb.org/gems/dry-struct/1.0/).
|
43
60
|
|
44
61
|
```ruby
|
45
62
|
# Example model file /model/demo/user.rb
|
46
63
|
module Demo
|
47
|
-
class
|
64
|
+
class User < Arcade::Vertex
|
48
65
|
attribute :name, Types::Nominal::String
|
49
|
-
timestamps true
|
50
66
|
|
51
67
|
def grandparents
|
52
68
|
db.query( "select in('is_family') from #{rid} ") &.allocate_model
|
@@ -58,14 +74,14 @@ __END__
|
|
58
74
|
CREATE INDEX on demo_user( name ) UNIQUE
|
59
75
|
```
|
60
76
|
|
61
|
-
Only the `name` attribute is declared.
|
77
|
+
Only the `name` attribute is declared.
|
62
78
|
|
63
|
-
`Demo::User.create_type` creates the type and executes
|
79
|
+
`Demo::User.create_type` creates the type and executes provided database-commands after __END__.
|
64
80
|
|
65
|
-
Other properties are schemaless.
|
81
|
+
Other properties are schemaless, but have to be declared in the model-file.
|
66
82
|
|
67
83
|
```ruby
|
68
|
-
Person.
|
84
|
+
Person.insert name: "Hubert", age: 35
|
69
85
|
Person.update set: { age: 36 }, where: { name: 'Hubert' }
|
70
86
|
persons = Person.where "age > 40"
|
71
87
|
persons.first.update age: 37
|
@@ -75,9 +91,66 @@ Person.all
|
|
75
91
|
Person.delete all: true || where: age: 56 , ...
|
76
92
|
```
|
77
93
|
|
94
|
+
### Nodes and Traverse
|
95
|
+
|
96
|
+
`ArcadeDB` wraps common queries of bidirectional connected vertices.
|
97
|
+
|
98
|
+
Suppose
|
99
|
+
```ruby
|
100
|
+
m = Person.create name: 'Hubert', age: '25'
|
101
|
+
f = Person.create name: 'Pauline', age: '28'
|
102
|
+
m.assign via: IsMarriedTo, vertex: f , divorced: false
|
103
|
+
|
104
|
+
```
|
105
|
+
This creates the simple graph
|
106
|
+
> Hubert --- is_married_to --> Pauline
|
107
|
+
> |
|
108
|
+
> -- divorced (attribute on the edge)
|
109
|
+
|
110
|
+
This can be queried through
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
hubert = Person.find name: 'Hubert'
|
114
|
+
pauline = hubert.nodes( :out, via: IsMarriedTo ).first
|
115
|
+
# or simply
|
116
|
+
pauline = hubert.out.first
|
117
|
+
|
118
|
+
```
|
119
|
+
Conditions may be set, to.
|
120
|
+
```ruby
|
121
|
+
hubert.nodes( :out, via: IsMarriedTo, where: "age < 30" )
|
122
|
+
```
|
123
|
+
gets all wives of hubert, who are younger then 30 years.
|
124
|
+
or
|
125
|
+
```ruby
|
126
|
+
Person.nodes( :outE, via: IsMarriedTo, where: { divorced: false } )
|
127
|
+
|
128
|
+
```
|
129
|
+
gets all wives where the divorced-condition, which is set on the edge, is false.
|
130
|
+
|
131
|
+
## Query
|
132
|
+
|
78
133
|
A **Query Preprocessor** is implemented. Its adapted from ActiveOrient. The [documentation](https://github.com/topofocus/active-orient/wiki/OrientQuery)
|
79
134
|
is still valid, however the class has changed to `Arcade::Query`.
|
80
135
|
|
136
|
+
## Match
|
137
|
+
|
138
|
+
A simple **Match Statement Generator** is provided for convenience. As the [declarative syntax](https://github.com/ArcadeData/arcadedb-docs/blob/main/src/main/asciidoc/sql/SQL-Match.adoc) seems to be very intuitive, a preprocessor should not be
|
139
|
+
necessary. With the help of some ruby magic, the creation of match-statements is simply an no-brainer.
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
a = Arcade::Match.new( type: Person, as: :persons)
|
143
|
+
.out( IsMarriedTo )
|
144
|
+
.node( where: 'age < 30')
|
145
|
+
a.to_s
|
146
|
+
=> Match { type: person, as: persons }.out('is_married_to'){ where: ( age < 30) } RETURN persons
|
147
|
+
|
148
|
+
a.execute.select_results # sends the statement to the database and returns Arcade Objects.
|
149
|
+
```
|
150
|
+
|
151
|
+
Arcade::Match-objects can be used as `from:` argument to Arcade::Query-Statements, thus hybrid queries are
|
152
|
+
easily constructed without extensive string-manipulations.
|
153
|
+
|
81
154
|
The **second Layer** handles Database-Requests.
|
82
155
|
In its actual implementation, these requests are delegated to the HTTP/JSON-API.
|
83
156
|
|
@@ -90,20 +163,18 @@ DB = Arcade::Init.db
|
|
90
163
|
$ DB.get nn, mm # returns a Aracde:Base object
|
91
164
|
# rid is either "#11:10:" or two numbers
|
92
165
|
$ DB.query querystring # returns either an Array of results (as Hash)
|
93
|
-
$ DB.execute { querystring } #
|
166
|
+
$ DB.execute { querystring } # execute a non idempotent query within a (nested) transaction
|
94
167
|
$ DB.create <name>, attribute: value .... # Creates a new <Document | Vertex> and returns the rid
|
95
168
|
# Operation is performed as Database-Transaction and is rolled back on error
|
96
|
-
$ DB.insert <name>, attribute: value .... # Inserts a new <Document | Vertex> and returns the
|
169
|
+
$ DB.insert <name>, attribute: value .... # Inserts a new <Document | Vertex> and returns the new object
|
97
170
|
$ DB.create_edge <name>, from: <rid> or [rid, rid, ..] , to: <rid> or [rid, rid, ..]
|
98
171
|
|
99
|
-
DB.query " Select from person where age > 40 "
|
100
|
-
DB.execute { " Update person set name='Hubert' return after $current where age = 36 " }
|
101
172
|
```
|
102
173
|
|
103
174
|
**Convert database input to Arcade::Base Models**
|
104
175
|
|
105
176
|
Either `DB.query` or `DB.execute` return the raw JSON-input from the database. It can always converted to model-objects by chaining
|
106
|
-
`
|
177
|
+
`allocate_model` or `select_result`.
|
107
178
|
|
108
179
|
```ruby
|
109
180
|
$ DB.query "select from my_names limit 1"
|
@@ -217,20 +288,24 @@ Select a range of nodes and perform a mathematical operation
|
|
217
288
|
-=> select median(note_count) from ( traverse out(connects) from #52:0 while $depth < 100 ) where $depth>=50
|
218
289
|
=> {:"median(note_count)"=>75.5 }
|
219
290
|
```
|
220
|
-
## Include in your own project
|
221
291
|
|
222
|
-
|
292
|
+
### Transactions
|
293
|
+
|
294
|
+
Database-Transactions are largely encapsulated
|
295
|
+
|
296
|
+
```
|
297
|
+
db = Arcade::Init.db
|
298
|
+
db.begin_transaction
|
299
|
+
|
300
|
+
{ perform insert, update, query, etc tasks in the database }
|
301
|
+
|
302
|
+
db.commit
|
303
|
+
|
304
|
+
# or
|
305
|
+
|
306
|
+
db.rollback
|
307
|
+
|
223
308
|
```
|
224
|
-
mkdir workspace && cd workspace
|
225
|
-
git clone https://github.com/topofocus/arcadedb
|
226
|
-
mkdir my-project && cd my-project
|
227
|
-
bundle init
|
228
|
-
cat "gem arcadedb, path='../arcadedb' " >> Gemfile
|
229
|
-
bundle install && bundle upate
|
230
|
-
cp ../arcadedb/config.yml .
|
231
|
-
mkdir bin
|
232
|
-
cp ../arcadedb/bin/console bin/
|
233
|
-
````
|
234
309
|
|
235
310
|
|
236
311
|
## Contributing
|
data/arcade.yml
CHANGED
@@ -1,26 +1,22 @@
|
|
1
1
|
---
|
2
|
-
## absolute path to the oetl-script
|
3
|
-
:pg:
|
4
|
-
:host: 10.247.8.109 # hierdevel
|
5
|
-
:port: 5432
|
6
2
|
:environment:
|
7
3
|
:test:
|
8
4
|
dbname: playground
|
9
5
|
user: root
|
10
|
-
pass:
|
6
|
+
pass: ***
|
11
7
|
:development:
|
12
8
|
dbname: devel
|
13
9
|
user: root
|
14
|
-
pass:
|
10
|
+
pass: ***
|
15
11
|
:production:
|
16
12
|
dbname: production
|
17
13
|
user: root
|
18
|
-
pass:
|
14
|
+
pass: ***
|
19
15
|
:admin:
|
20
16
|
:host: 10.247.8.109
|
21
17
|
:port: 2480
|
22
18
|
:user: root
|
23
|
-
:pass:
|
19
|
+
:pass: ***
|
24
20
|
:logger: stdout # 'file' or 'stdout'
|
25
21
|
:namespace: Arcade # Default Namespace
|
26
22
|
:autoload: true # load model if a link is detected in a record
|
data/arcadedb.gemspec
CHANGED
@@ -23,13 +23,10 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 2"
|
24
24
|
spec.add_development_dependency "rake", "~> 13.0"
|
25
25
|
spec.add_development_dependency "rspec", "~> 4.0"
|
26
|
-
|
27
|
-
# spec.add_dependency 'activemodel'
|
28
|
-
spec.add_dependency "typhoeus"
|
26
|
+
spec.add_dependency "httpx"
|
29
27
|
spec.add_dependency 'dry-schema'
|
30
28
|
spec.add_dependency 'dry-struct'
|
31
29
|
spec.add_dependency 'dry-core'
|
32
|
-
|
33
|
-
#
|
34
|
-
# spec.add_dependency 'mini_sql'
|
30
|
+
spec.add_dependency 'dry-configurable'
|
31
|
+
# spec.add_dependency 'dry-monads' # future use
|
35
32
|
end
|
data/bin/console
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
## loads the
|
2
|
+
## loads the arcadeDB environment
|
3
3
|
## and starts an interactive shell
|
4
4
|
##
|
5
|
-
## Parameter:
|
5
|
+
## Parameter:
|
6
6
|
## production (p)
|
7
7
|
## development (d) [default]
|
8
8
|
## test (t)
|
9
9
|
require 'bundler/setup'
|
10
|
-
require 'terminal-table'
|
10
|
+
#require 'terminal-table'
|
11
11
|
require 'zeitwerk'
|
12
12
|
require 'pastel'
|
13
13
|
require 'arcade'
|
14
|
-
require 'pry'
|
14
|
+
#require 'pry'
|
15
15
|
#begin
|
16
16
|
|
17
17
|
|
@@ -66,10 +66,6 @@ def browse db: Arcade::Api.databases.first , extended: false
|
|
66
66
|
end
|
67
67
|
|
68
68
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
69
|
include Arcade
|
74
70
|
|
75
71
|
def help
|
@@ -106,21 +102,25 @@ end
|
|
106
102
|
|
107
103
|
help
|
108
104
|
e= ARGV.empty? ? :development : ARGV.last.downcase.to_sym
|
109
|
-
## load test model files
|
110
|
-
#require "#{__dir__}/../spec/model_helper"
|
111
|
-
|
112
105
|
loader = Zeitwerk::Loader.new
|
113
|
-
|
106
|
+
if e.to_s[0] == 't'
|
107
|
+
loader.push_dir ("#{__dir__}/../spec/model")
|
108
|
+
else
|
109
|
+
loader.push_dir ("#{__dir__}/../lib/model")
|
110
|
+
|
111
|
+
end
|
114
112
|
loader.setup
|
115
113
|
puts "DB = Arcade::Database-instance"
|
116
114
|
DB = Arcade::Init.connect e
|
117
115
|
#require 'pry'
|
116
|
+
#if e.to_s[0] == 't'
|
117
|
+
# DB.create_type :document, 'test_document'
|
118
|
+
# DB.create_type :vertex, :test_vertex
|
119
|
+
#
|
120
|
+
#end
|
118
121
|
require 'irb'
|
119
122
|
ARGV.clear
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
#
|
124
|
-
## retry
|
125
|
-
#end
|
126
|
-
Pry.start(__FILE__)
|
123
|
+
|
124
|
+
IRB.start(__FILE__)
|
125
|
+
|
126
|
+
#Pry.start(__FILE__)
|