A Clojure driver for OrientDB binary protocol.
Add the necessary dependency to your project:
[eu.7bridges/clj-odbp "0.2.3"]
clj-odbp comes with default settings with regard to OrientDB connection
and logging.
user> (require '[clj-odbp.configure :as c])
user> @c/config
;; => {:log-level :fatal, :log-file "log/clj_odbp.log", :port 2424, :host "localhost", :log-rotation-frequency :daily}
To change the default settings, you need to use
clj-odbp.configure/configure-driver.
user> (c/configure-driver {:host "my-orientdb-server" :log-level :debug})
user> @c/config
;; => {:log-level :debug, :log-file "log/clj_odbp.log", :port 2424, :host "my-orientdb-server", :log-rotation-frequency :daily}
Connect to an OrientDB server:
user> (require '[clj-odbp.core :as odbp])
user> (odbp/connect-server "<username>" "<password>")
Create a new database:
user> (let [connection (odbp/connect-server "<username>" "<password>")]
(odbp/db-create connection "test-db"))
Check if a database exists:
user> (let [connection (odbp/connect-server "<username>" "<password>")]
(odbp/db-exist connection "test-db"))
Connect to a database and create a vertex:
user> (let [connection (odbp/db-open "test-db" "<username>" "<password>")]
(odbp/execute-command connection "create class Test extends V"))
Connect to a database and create a record:
user> (let [connection (odbp/db-open "test-db" "<username>" "<password>")]
(odbp/record-create connection {:_class "Test" :text "test property"}))
For further details check API documentation.
The following table shows how OrientDB types map to Clojure types and viceversa.
| OrientDB | Clojure |
|---|---|
| boolean | true, false |
| integer | (int 42) |
| short | (short 42) |
| long | 42 |
| float | (float 42.5) |
| double | 42.5 |
| decimal | (bigdec 42.5) |
| string | "foo" |
| binary | {:_obinary [100 101]} |
| date | not supported |
| datetime | (java.util.Date.) |
| embedded | {:_version 0 :_class "Test" :name "foo"} |
| embedded list | [0 "foo" 1] |
| embedded set | #{0 "foo" 1} |
| embedded map | {:name "foo" :age 42} |
| link | "#20:1" |
| link list | ["#20:1" "#20:2"] |
| link set | #{"#20:1" "#20:2"} |
| link map | {"rid" "#20:1"} |
| ORidBag | {:_oridbag {:bag []}} |
| ORidTree | {:_oridtree {:changes []}} |
Copyright © 2017 7bridges s.r.l.
Distributed under the Apache License 2.0.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |