From 9a482cf3713f273dd44e08c5be9821ab0c0cdc36 Mon Sep 17 00:00:00 2001 From: Christian Himpe Date: Tue, 12 Mar 2024 21:58:25 +0100 Subject: [PATCH] rc 0.8 --- README.md | 36 ++++++++++++++++++++-------------- arcadedb.egg | 6 +++--- arcadedb.release-info | 3 ++- arcadedb.scm | 45 +++++++++++++++++++++++++------------------ arcadedb.wiki | 33 +++++++++++++++++-------------- 5 files changed, 72 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index ff7c87a..3ac2aca 100644 --- a/README.md +++ b/README.md @@ -29,14 +29,15 @@ as well as providing a JSON / REST-like / HTTP API. The native query language of **ArcadeDB** is a dialect of SQL, closely related to _OrientDB_'s OSQL, which supports the [SQL command categories](https://www.geeksforgeeks.org/sql-ddl-dql-dml-dcl-tcl-commands/): -* **DDL** - Data Definition Language, via `CREATE`, `DROP`, `ALTER`, `TRUNCATE` of `TYPE`s +* **DDL** - Data Definition Language, via `CREATE`, `DROP`, `ALTER`, `TRUNCATE` of `TYPE`s and `PROPERTY`s * **DQL** - Data Query Language, via `SELECT`, `TRAVERSE`, `MATCH` -* **DML** - Data Manipulation Language, via `INSERT`, `UPDATE`, `DROP`, `EXPLAIN`, `PROFILE` +* **DML** - Data Manipulation Language, via `INSERT`, `UPDATE`, `DROP`, `CREATE VERTEX`, `CREATE EDGE`, `MOVE VERTEX` +* **TCL** - Transaction Control Language, via `BEGIN`, `COMMIT`, `ROLLBACK` -for the remaining categories holds: +for the remaining category holds: * **DCL** - Data Control Language, does not apply due to only [server level users](https://docs.arcadedb.com/#Security) -* **TCL** - Transaction Control Language, via [HTTP REST endpoints](https://docs.arcadedb.com/#HTTP-API) + ## About `arcadedb` @@ -63,10 +64,8 @@ Furthermore, the `arcadedb` module requires `wget` for the HTTP requests: * [wget](https://www.gnu.org/software/wget/) -during runtime, and imports the `uri-common` egg to url-encode strings, -as well as the `medea` egg to decode JSON: +during runtime, and imports the `medea` egg to decode JSON: -* [uri-common](https://wiki.call-cc.org/eggref/5/uri-common) * [medea](https://wiki.call-cc.org/eggref/5/medea) ## Local Server Setup @@ -107,6 +106,13 @@ Returns **alist** with single entry if connection to server using **string**s `user`, `pass`, `host`, and optionally **number** `port`, succeded; returns `#f` if a server error occurs or no response is received. +#### a-clear +``` +(a-clear) +``` + +Returns `true` after clearing internal parameters `server` and `secret`. + ### Server Information #### a-ready? @@ -279,19 +285,20 @@ Returns **boolean** that is true if automatic repair succeeded. #### a-metadata ``` -(a-metadata id key value) +(a-metadata id key . value) ``` -Returns **boolean** that is true if adding custom attribute -with **symbol** `key` and **string** `value` to type or property **symbol** `id` succeeded. +Returns the value of the custom attribute with **symbol** `key` of type or property **symbol** `id`, +if `value` is not passed. +Returns **boolean** that is true if setting custom attribute **symbol** `key` +with **string** or **number** `value` succeded. #### a-comment ``` (a-comment) -(a-comment msg) +(a-comment . msg) ``` -Returns **string** current database comment of current database, if `msg` is not passed; -returns `#t` if setting **string** `msg` as comment for current database succeded; -returns `#f` if no comment is set, a server error occurs or no response is received. +Returns **string** being database comment of current database, if **string** `msg` is not passed. +Returns **boolean** that is true if setting database comment **string** `msg` succeded. This function emulates the SQL `COMMENT ON DATABASE` statement, by creating a type `sys` and upserting or reading the first `comment` property. @@ -305,6 +312,7 @@ by creating a type `sys` and upserting or reading the first `comment` property. * `0.5` [Major Update](https://github.com/gramian/chicken-arcadedb) (2023-03-01) * `0.6` [Major Update](https://github.com/gramian/chicken-arcadedb) (2023-05-05) * `0.7` [Minor Update](https://github.com/gramian/chicken-arcadedb) (2023-09-29) +* `0.8` [Major Update](https://github.com/gramian/chicken-arcadedb) (2024-03-12) ## License diff --git a/arcadedb.egg b/arcadedb.egg index ec9ce36..5a758ed 100644 --- a/arcadedb.egg +++ b/arcadedb.egg @@ -1,12 +1,12 @@ ;;;; arcadedb.egg -((version "0.7") +((version "0.8") (synopsis "An ArcadeDB database driver for CHICKEN Scheme.") (author "Christian Himpe") (category db) (license "ZLIB-Acknowledgement") - (dependencies uri-common medea) - (foreign-dependencies curl) + (dependencies medea) + (foreign-dependencies wget) (platform (not windows)) (components (extension arcadedb (csc-options "-O3" "-d0" "-C" "-O2"))) ) diff --git a/arcadedb.release-info b/arcadedb.release-info index 7746339..e75295d 100644 --- a/arcadedb.release-info +++ b/arcadedb.release-info @@ -8,4 +8,5 @@ (release "0.4") (release "0.5") (release "0.6") -(release "0.7") \ No newline at end of file +(release "0.7") +(release "0.8") \ No newline at end of file diff --git a/arcadedb.scm b/arcadedb.scm index c55ddfc..e17f2b9 100644 --- a/arcadedb.scm +++ b/arcadedb.scm @@ -1,7 +1,7 @@ ;;;; ArcadeDB CHICKEN Scheme Module ;;@project: chicken-arcadedb -;;@version: 0.7 (2023-09-29) +;;@version: 0.8 (2024-03-12) ;;@authors: Christian Himpe (0000-0003-2194-6754) ;;@license: zlib-acknowledgement (spdx.org/licenses/zlib-acknowledgement.html) ;;@summary: An ArcadeDB database driver for CHICKEN Scheme @@ -9,7 +9,7 @@ (module arcadedb (a-help - a-server + a-server a-clear a-ready? a-version a-list a-exist? a-new a-delete @@ -22,10 +22,9 @@ a-backup a-stats a-health a-repair - a-metadata - a-comment) + a-metadata a-comment) - (import scheme (chicken base) (chicken io) (chicken string) (chicken process) (chicken pathname) uri-common medea) + (import scheme (chicken base) (chicken io) (chicken string) (chicken process) (chicken pathname) medea) (print "\n; arcadedb: call `(a-help)` for a procedure overview.\n") @@ -73,6 +72,7 @@ " (a-help) - Display this message\n" "\n" " (a-server user pass host . port) - Set remote server\n" + " (a-clear) - Unset server\n" "\n" " (a-ready?) - Is server ready?\n" " (a-version) - Server version\n" @@ -84,7 +84,7 @@ " (a-delete db) - Drop database\n" "\n" " (a-use db) - Connect database\n" - " (a-using) - Connected database\n" + " (a-using) - Get connected database\n" "\n" " (a-query lang query) - Database query\n" " (a-command lang cmd) - Database command\n" @@ -99,8 +99,8 @@ " (a-stats) - Database statistics\n" " (a-health) - Database health\n" " (a-repair) - Repair database\n" - " (a-metadata id key value) - Add metadata\n" - " (a-comment [msg]) - Database comment\n" + " (a-metadata id key . value) - Get or set custom metadata\n" + " (a-comment . msg) - Get or set database comment\n" "\n" " For more info see: https://wiki.call-cc.org/eggref/5/arcadedb\n")) @@ -113,6 +113,12 @@ (secret (cons user pass)) '((arcadedb . "Hello"))) +;;@returns: `true`, after clearing internal parameters `server` and `secret`. +(define (a-clear) + (server #f) + (secret #f) + #t) + ;;; Server Information ######################################################### ;;@returns: **boolean** answering if server is ready. @@ -209,8 +215,8 @@ ;;@returns **flonum** being the Jaccard similarity index, given a **symbol** `type` and two **symbol** arguments `x` and `y`. (define (a-jaccard type x y) (assert (and (symbol? type) (symbol? x) (symbol? y))) - (cdaar (a-command 'sqlscript (string-append "SELECT intersect($t[0].x,$t[0].y).size().asFloat() / unionall($t[0].x,$t[0].y).size().asFloat()" - "LET $t = (SELECT unionall(" (symbol->string x) ") AS x, unionall(" (symbol->string y) ") AS y FROM " (symbol->string type)");")))) + (cdaar (a-command 'sql (string-append "SELECT intersect($t[0].x,$t[0].y).size().asFloat() / unionall($t[0].x,$t[0].y).size().asFloat()" + "LET $t = (SELECT unionall(" (symbol->string x) ") AS x, unionall(" (symbol->string y) ") AS y FROM " (symbol->string type)");")))) ;;@returns: **boolean** that is true if backing-up current database succeeded. (define (a-backup) @@ -232,17 +238,18 @@ (not (not (a-command 'sql "CHECK DATABASE FIX;")))) ;;@returns: **boolean** that is true if adding custom attribute with **symbol** `key` and **string** `value` to type or property **symbol** `id` succeeded. -(define (a-metadata id key value) - (assert (and (symbol? id) (symbol? key) (or (string? value) (number? value)))) - (and (a-command 'sql (string-append "ALTER " (if (substring-index "." (symbol->string id)) "PROPERTY" "TYPE") " " (symbol->string id) - " CUSTOM " (symbol->string key) " = " (if (string? value) (string-append "\"" value "\"") (number->string value)) ";")) #t)) +(define (a-metadata id key . value) + (assert (and (symbol? id) (symbol? key))) + (if (null? value) + (let [(res (a-query 'sql (string-append "SELECT custom." (symbol->string key) " FROM schema:types WHERE name = \"" (symbol->string id) "\";")))] + (and (not (null? res)) (not (eqv? (cdaar res) 'null)) (cdaar res))) + (and (a-command 'sql (string-append "ALTER " (if (substring-index "." (symbol->string id)) "PROPERTY" "TYPE") " " (symbol->string id) + " CUSTOM " (symbol->string key) " = " (if (string? (car value)) (string-append "\"" (car value) "\"") (number->string (car value))) ";")) #t))) ;;@returns: **string** comment, or `#t` if **string** `msg` is passed. (define (a-comment . msg) - (and (a-command 'sql (string-append "CREATE DOCUMENT TYPE sys IF NOT EXISTS;")) - (if (null? msg) (let [(res (a-query 'sql (string-append "SELECT comment FROM sys WHERE on = \"database\" LIMIT 1;")))] - (and res (not (null? res)) (not (null? (car res))) (alist-ref 'comment (car res)))) - (let [(str (car msg))] - (and (string? str) (a-command 'sql (string-append "UPDATE sys SET comment = \"" str "\" UPSERT WHERE on = \"database\";")) #t))))) + (and (a-command 'sql (string-append "CREATE VERTEX TYPE " (symbol->string (active)) " IF NOT EXISTS;")) + (if (null? msg) (a-metadata (active) 'comment) + (a-metadata (active) 'comment (car msg))))) ) ; end module diff --git a/arcadedb.wiki b/arcadedb.wiki index b133052..1a6cd6f 100644 --- a/arcadedb.wiki +++ b/arcadedb.wiki @@ -30,14 +30,14 @@ as well as providing a JSON / REST-like / HTTP API. The native query language of '''ArcadeDB''' is a dialect of SQL, closely related to ''OrientDB'''s OSQL, which supports the [[https://www.geeksforgeeks.org/sql-ddl-dql-dml-dcl-tcl-commands/|SQL command categories]]: -* '''DDL''' - Data Definition Language, via {{CREATE}}, {{DROP}}, {{ALTER}}, {{TRUNCATE}} of {{TYPE}}s +* '''DDL''' - Data Definition Language, via {{CREATE}}, {{DROP}}, {{ALTER}}, {{TRUNCATE}} of {{TYPE}}s and {{PROPERTY}}s * '''DQL''' - Data Query Language, via {{SELECT}}, {{TRAVERSE}}, {{MATCH}} -* '''DML''' - Data Manipulation Language, via {{INSERT}}, {{UPDATE}}, {{DROP}}, {{EXPLAIN}}, {{PROFILE}} +* '''DML''' - Data Manipulation Language, via {{INSERT}}, {{UPDATE}}, {{DROP}}, {{CREATE VERTEX}}, {{CREATE EDGE}}, {{MOVE VERTEX}} +* '''TCL''' - Transaction Control Language, via {{BEGIN}}, {{COMMIT}}, {{ROLLBACK}} -for the remaining categories holds: +for the remaining category holds: * '''DCL''' - Data Control Language, does not apply due to only [[https://docs.arcadedb.com/#Security|server level users]] -* '''TCL''' - Transaction Control Language, via [[https://docs.arcadedb.com/#HTTP-API|HTTP REST endpoints]] == About {{arcadedb}} @@ -64,10 +64,8 @@ Furthermore, the {{arcadedb}} module requires {{wget}} for the HTTP requests: * [[https://www.gnu.org/software/wget/|wget]] -during runtime, and imports the {{uri-common}} egg to url-encode strings, -as well as the {{medea}} egg to decode JSON: +during runtime, and imports the {{medea}} egg to decode JSON: -* [[https://wiki.call-cc.org/eggref/5/uri-common|uri-common]] * [[https://wiki.call-cc.org/eggref/5/medea|medea]] == Local Server Setup @@ -106,6 +104,11 @@ Returns '''alist''' with single entry if connection to server using '''string''' {{user}}, {{pass}}, {{host}}, and optionally '''number''' {{port}}, succeded; returns {{#f}} if a server error occurs or no response is received. +==== a-clear +(a-clear) + +Returns {{true}} after clearing internal parameters {{server}} and {{secret}}. + === Server Information ==== a-ready? @@ -257,18 +260,19 @@ returns {{#f}} if a server error occurs or no response is received. Returns '''boolean''' that is true if automatic repair succeeded. ==== a-metadata -(a-metadata id key value) +(a-metadata id key . value) -Returns '''boolean''' that is true if adding custom attribute -with '''symbol''' {{key}} and '''string''' {{value}} to type or property '''symbol''' {{id}} succeeded. +Returns the value of the custom attribute with '''symbol''' {{key}} of type or property '''symbol''' {{key}}, +if {{value}} is not passed. +Returns '''boolean''' that is true if setting custom attribute '''symbol''' {{key}} +with '''string''' or '''number''' {{value}} succeded. ==== a-comment (a-comment) -(a-comment msg) +(a-comment . msg) -Returns '''string''' current database comment of current database, if {{msg}} is not passed; -returns {{#t}} if '''string''' {{msg}} was set as comment for current database succeded; -returns {{#f}} if no comment is set, a server error occurs or no response is received. +Returns '''string''' being database comment of current database, if '''string''' {{msg}} is not passed. +Returns '''boolean''' that is true if setting database comment '''string''' {{msg}} succeded. This function emulates the SQL {{COMMENT ON DATABASE}} statement, by creating a type {{sys}} and upserting or reading the first {{comment}} property. @@ -282,6 +286,7 @@ by creating a type {{sys}} and upserting or reading the first {{comment}} proper * {{0.5}} [[https://github.com/gramian/chicken-arcadedb|Major Update]] (2023-03-01) * {{0.6}} [[https://github.com/gramian/chicken-arcadedb|Major Update]] (2023-05-05) * {{0.7}} [[https://github.com/gramian/chicken-arcadedb|Minor Update]] (2023-09-29) +* {{0.8}} [[https://github.com/gramian/chicken-arcadedb|Major Update]] (2024-03-12) == License