Git Product home page Git Product logo

clj-odbp's Introduction

This project is no longer maintained, because we are no longer interested in OrientDB.

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.

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 []}}

License

Copyright © 2017 7bridges s.r.l.

Distributed under the Apache License 2.0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.