arcadedb 0.4 → 0.5.0
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 +4 -4
- data/CHANGELOG.md +15 -1
- data/Gemfile.lock +2 -36
- data/README.md +105 -30
- data/arcade.yml +4 -4
- data/bin/console +16 -16
- 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 +26 -65
- data/lib/arcade/api/primitives.rb +57 -29
- data/lib/arcade/base.rb +72 -39
- data/lib/{config.rb → arcade/config.rb} +5 -6
- data/lib/arcade/database.rb +104 -154
- data/lib/arcade/errors.rb +8 -0
- data/lib/arcade/match.rb +162 -0
- data/lib/{query.rb → arcade/query.rb} +34 -18
- data/lib/{support → arcade/support}/conversions.rb +1 -0
- data/lib/{support → arcade/support}/model.rb +20 -15
- data/lib/arcade/version.rb +1 -1
- data/lib/arcade.rb +11 -11
- data/lib/model/document.rb +22 -0
- data/lib/model/edge.rb +12 -0
- data/lib/model/vertex.rb +67 -48
- metadata +15 -12
- 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
@@ -15,5 +15,19 @@ All notable changes to this project will be documented in this file.
|
|
15
15
|
## 0.4.0 - 2023.10.28
|
16
16
|
- completely remove pg-stuff
|
17
17
|
- substitute typhoreous with HTTPX
|
18
|
-
- include dry::monards to process raw-data
|
19
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.lock
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
arcadedb (0.4)
|
4
|
+
arcadedb (0.4.1)
|
5
5
|
dry-configurable
|
6
6
|
dry-core
|
7
|
-
dry-monads
|
8
7
|
dry-schema
|
9
8
|
dry-struct
|
10
9
|
httpx
|
@@ -12,9 +11,7 @@ PATH
|
|
12
11
|
GEM
|
13
12
|
remote: https://rubygems.org/
|
14
13
|
specs:
|
15
|
-
ast (2.4.2)
|
16
14
|
awesome_print (1.9.2)
|
17
|
-
base64 (0.1.1)
|
18
15
|
coderay (1.1.3)
|
19
16
|
concurrent-ruby (1.2.2)
|
20
17
|
diff-lcs (1.5.0)
|
@@ -30,10 +27,6 @@ GEM
|
|
30
27
|
concurrent-ruby (~> 1.0)
|
31
28
|
dry-core (~> 1.0, < 2)
|
32
29
|
zeitwerk (~> 2.6)
|
33
|
-
dry-monads (1.6.0)
|
34
|
-
concurrent-ruby (~> 1.0)
|
35
|
-
dry-core (~> 1.0, < 2)
|
36
|
-
zeitwerk (~> 2.6)
|
37
30
|
dry-schema (1.13.3)
|
38
31
|
concurrent-ruby (~> 1.0)
|
39
32
|
dry-configurable (~> 1.0, >= 1.0.1)
|
@@ -72,11 +65,9 @@ GEM
|
|
72
65
|
guard-compat (~> 1.1)
|
73
66
|
rspec (>= 2.99.0, < 4.0)
|
74
67
|
http-2-next (1.0.1)
|
75
|
-
httpx (1.0
|
68
|
+
httpx (1.1.0)
|
76
69
|
http-2-next (>= 1.0.1)
|
77
70
|
ice_nine (0.11.2)
|
78
|
-
json (2.6.3)
|
79
|
-
language_server-protocol (3.17.0.3)
|
80
71
|
listen (3.8.0)
|
81
72
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
82
73
|
rb-inotify (~> 0.9, >= 0.9.10)
|
@@ -86,10 +77,6 @@ GEM
|
|
86
77
|
notiffany (0.1.3)
|
87
78
|
nenv (~> 0.1)
|
88
79
|
shellany (~> 0.0)
|
89
|
-
parallel (1.23.0)
|
90
|
-
parser (3.2.2.4)
|
91
|
-
ast (~> 2.4.1)
|
92
|
-
racc
|
93
80
|
pastel (0.8.0)
|
94
81
|
tty-color (~> 0.5)
|
95
82
|
pry (0.14.2)
|
@@ -97,16 +84,12 @@ GEM
|
|
97
84
|
method_source (~> 1.0)
|
98
85
|
psych (5.1.1.1)
|
99
86
|
stringio
|
100
|
-
racc (1.7.1)
|
101
|
-
rainbow (3.1.1)
|
102
87
|
rake (13.0.6)
|
103
88
|
rb-fsevent (0.11.2)
|
104
89
|
rb-inotify (0.10.1)
|
105
90
|
ffi (~> 1.0)
|
106
91
|
rdoc (6.5.0)
|
107
92
|
psych (>= 4.0.0)
|
108
|
-
regexp_parser (2.8.2)
|
109
|
-
rexml (3.2.6)
|
110
93
|
rspec (3.12.0)
|
111
94
|
rspec-core (~> 3.12.0)
|
112
95
|
rspec-expectations (~> 3.12.0)
|
@@ -131,21 +114,6 @@ GEM
|
|
131
114
|
diff-lcs (>= 1.2.0, < 2.0)
|
132
115
|
rspec-support (~> 3.12.0)
|
133
116
|
rspec-support (3.12.1)
|
134
|
-
rubocop (1.57.1)
|
135
|
-
base64 (~> 0.1.1)
|
136
|
-
json (~> 2.3)
|
137
|
-
language_server-protocol (>= 3.17.0)
|
138
|
-
parallel (~> 1.10)
|
139
|
-
parser (>= 3.2.2.4)
|
140
|
-
rainbow (>= 2.2.2, < 4.0)
|
141
|
-
regexp_parser (>= 1.8, < 3.0)
|
142
|
-
rexml (>= 3.2.5, < 4.0)
|
143
|
-
rubocop-ast (>= 1.28.1, < 2.0)
|
144
|
-
ruby-progressbar (~> 1.7)
|
145
|
-
unicode-display_width (>= 2.4.0, < 3.0)
|
146
|
-
rubocop-ast (1.29.0)
|
147
|
-
parser (>= 3.2.1.0)
|
148
|
-
ruby-progressbar (1.13.0)
|
149
117
|
sdoc (2.6.1)
|
150
118
|
rdoc (>= 5.0)
|
151
119
|
shellany (0.0.1)
|
@@ -168,7 +136,6 @@ DEPENDENCIES
|
|
168
136
|
guard
|
169
137
|
guard-rspec
|
170
138
|
pastel
|
171
|
-
pry
|
172
139
|
rake (~> 13.0)
|
173
140
|
rb-inotify
|
174
141
|
rspec
|
@@ -177,7 +144,6 @@ DEPENDENCIES
|
|
177
144
|
rspec-given
|
178
145
|
rspec-its
|
179
146
|
rspec-legacy_formatters
|
180
|
-
rubocop
|
181
147
|
sdoc
|
182
148
|
terminal-table
|
183
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
@@ -3,20 +3,20 @@
|
|
3
3
|
:test:
|
4
4
|
dbname: playground
|
5
5
|
user: root
|
6
|
-
pass:
|
6
|
+
pass: ***
|
7
7
|
:development:
|
8
8
|
dbname: devel
|
9
9
|
user: root
|
10
|
-
pass:
|
10
|
+
pass: ***
|
11
11
|
:production:
|
12
12
|
dbname: production
|
13
13
|
user: root
|
14
|
-
pass:
|
14
|
+
pass: ***
|
15
15
|
:admin:
|
16
16
|
:host: 10.247.8.109
|
17
17
|
:port: 2480
|
18
18
|
:user: root
|
19
|
-
:pass:
|
19
|
+
:pass: ***
|
20
20
|
:logger: stdout # 'file' or 'stdout'
|
21
21
|
:namespace: Arcade # Default Namespace
|
22
22
|
:autoload: true # load model if a link is detected in a record
|
data/bin/console
CHANGED
@@ -1,13 +1,13 @@
|
|
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'
|
@@ -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
|
-
|
123
|
+
|
121
124
|
IRB.start(__FILE__)
|
122
|
-
|
123
|
-
# puts e
|
124
|
-
## retry
|
125
|
-
#end
|
125
|
+
|
126
126
|
#Pry.start(__FILE__)
|