Skip to content

Commit

Permalink
Merge pull request #292 from gramian/main
Browse files Browse the repository at this point in the history
Some extensions
  • Loading branch information
mergify[bot] authored Nov 14, 2024
2 parents 660d8db + 30467e6 commit bd63aaa
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 4 deletions.
19 changes: 17 additions & 2 deletions src/main/asciidoc/api/clojure.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ In the following, the use of the ArcadeDB Java API from Clojure is exemplified
using Clojure-as-a-jar for simplicity, see https://curiousprogrammer.net/posts/2023-09-18_run-clojure-repl-with-plain-java[this article];
however Clojure projects build with Leiningen (or alike) are similarly compatible.



Typically two classes need to be imported:
`DatabaseFactory` and `Result`
```clojure
Expand Down Expand Up @@ -96,3 +94,20 @@ Altogether, here is the full Clojure AradeDB example:

(.close db)
```

To start an ArcadeDB server from Clojure, as in the <<_start-the-server-in-the-jvm,Embedded Server>> section, use:
```clojure
(import (com.arcadedb ContextConfiguration
server.ArcadeDBServer))

(def config (ContextConfiguration.))
(def server (ArcadeDBServer. config))

(.start server)

(def db (.getOrCreateDatabase server "mydb"))

;; ... more code

(.stop server)
```
1 change: 0 additions & 1 deletion src/main/asciidoc/api/java-ref-database.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ To obtain an instance of Database, use the class `<<DatabaseFactory,DatabaseFact
|<<_transaction-txblock,transaction() default>>
|<<_transaction-txblock-retries,transaction() with retries>>
|
|
|===

===== Methods (By category)
Expand Down
9 changes: 9 additions & 0 deletions src/main/asciidoc/appendix/sql-syntax.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,15 @@ The result of this filtering is ALWAYS a single value.
- `<range>`: A range is something like `M..N` or `M...N` where M and N are integer/long numbers, eg. `fieldName[2..5]`. The result of range filtering is a collection that is a subet of the original field value, containing all the items from position M (included) to position N (excluded for `..`, included for `...`). Eg. if `fieldName = ['a', 'b', 'c', 'd', 'e']`, `fieldName[1..3] = ['b', 'c']`, `fieldName[1...3] = ['b', 'c', 'd']`. Ranges start from `0`. The result of this filtering is ALWAYS a list (ordered collection, allowing duplicates). If the original collection was ordered, then the result will preserve the order.
- `<condition>`: A normal SQL condition, that is applied to each element in the `fieldName` collection. The result is a sub-collection that contains only items that match the condition. Eg. `fieldName = [{foo = 1},{foo = 2},{foo = 5},{foo = 8}]`, `fieldName[foo > 4] = [{foo = 5},{foo = 8}]`. The result of this filtering is ALWAYS a list (ordered collection, allowing duplicates). If the original collection was ordered, then the result will preserve the order.

[[SQL-Curly]]
**Nested projections**

Colon prefixed curly braces can be used to project maps or JSON documents.

`map:{ ( * | (([!]<identifier>[\*] | <expression>) [AS <identifier>] [,*] ) }`

As for projections in the `SELECT` statement, nested projection consist of a comma spearated list of projections.
For further details and examples, see <<_nested-projections,nested projections>>.

**Conditions**

Expand Down
17 changes: 17 additions & 0 deletions src/main/asciidoc/sql/SQL-Projections.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,20 @@ SELECT name, parent.parent:{name, surname} as grandparent FROM TheType WHERE nam
}
}
----

Finally, you can rename fields with `AS`:

[source,sql]
----
SELECT name, parent.parent:{name AS givenname} as grandparent FROM TheType WHERE name = 'baz'
----

[source,json]
----
{
"name": "baz",
"grandparent": {
"givenname": "fooz"
}
}
----
3 changes: 3 additions & 0 deletions src/main/asciidoc/sql/SQL-Script.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ The following list highlights the differences between `sql` and `sqlscript`:
* A `sqlscript` batch is automatically transaction, a `sql` query or command by itself is not.
* `sqlscript` supports additional control flow constructs (i.e. loops and conditionals, see below).

NOTE: Given that `sqlscript` always induces transactions,
the transaction atomicity prerequisite of "all-or-nothing" applies to every `sqlscript` script.

SQL Script supports all the ArcadeDB <<SQL-Commands,SQL Commands>>, plus the following:

* `BEGIN [isolation &lt;isolation-level&gt;]`, where `&lt;isolation-level&gt;` can be `READ_COMMITTED`, `REPEATABLE_READ`. By default is `READ_COMMITTED`
Expand Down
2 changes: 1 addition & 1 deletion src/main/asciidoc/studio/graph.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
|===
|image:../images/studio-graph-node-menu-unselected.png[align="left",scaledwidth=30%]|Hold the selection on a node to show its context menu.
Then while still holding the selection, slide on the action to execute and then release the selection.
|image:../images/studio-graph-node-menu-selected.png[align="right",scaledwidth=30%] |
|image:../images/studio-graph-node-menu-selected.png[align="right",scaledwidth=30%]
|===

The context menu has the following actions:
Expand Down

0 comments on commit bd63aaa

Please sign in to comment.