Liking cljdoc? Tell your friends :D

7bridges clj-odbp

clj-odbp

A Clojure driver for OrientDB binary protocol.

Build Status Clojars Project

Installation

Add the necessary dependency to your project:

[eu.7bridges/clj-odbp "0.2.3"]

Usage

Driver configuration

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}

Driver usage

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.

Types

The following table shows how OrientDB types map to Clojure types and viceversa.

OrientDBClojure
booleantrue, false
integer(int 42)
short(short 42)
long42
float(float 42.5)
double42.5
decimal(bigdec 42.5)
string"foo"
binary{:_obinary [100 101]}
datenot 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 []}}

License

Copyright © 2017 7bridges s.r.l.

Distributed under the Apache License 2.0.

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close