Orientdb4r
Ruby binding for Orient DB
Install / Use
/learn @veny/Orientdb4rREADME
_ _ _ _ _ _
___ _ __(_) ___ _ __ | |_ __| | |__ | || | _ __
/ _ | '| |/ _ \ '_ | / ` | ' | || |_| '| | () | | | | __/ | | | || (| | |_) | | | ___/|| ||___|| ||__,|.__/ || |_|
= Ruby binding for Orient DB
A Ruby client for the NoSQL Graph/Document database Orient DB (http://orientdb.org).
{<img src="https://badge.fury.io/rb/orientdb4r.svg" alt="Gem Version" />}[http://badge.fury.io/rb/orientdb4r] {<img src="https://secure.travis-ci.org/veny/orientdb4r.png" alt="Build Status" />}[http://travis-ci.org/veny/orientdb4r] {<img src="https://coveralls.io/repos/veny/orientdb4r/badge.svg?branch=master" alt="Coverage Status" />}[https://coveralls.io/r/veny/orientdb4r?branch=master]
== USAGE
see Wiki page for more sample at https://github.com/veny/orientdb4r/wiki
require 'orientdb4r'
DB = 'foo' CLASS = 'myclass'
client = Orientdb4r.client # equivalent for :host => 'localhost', :port => 2480, :ssl => false
client.database_exists? :database => DB, :user => 'admin', :password => 'admin' => false
client.create_database :database => DB, :storage => :memory, :user => 'root', :password => 'root' => false
client.connect :database => DB, :user => 'admin', :password => 'admin' => true
unless client.class_exists? CLASS client.create_class(CLASS) do |c| c.property 'prop1', :integer, :notnull => true, :min => 1, :max => 99 c.property 'prop2', :string, :mandatory => true c.link 'users', :linkset, 'OUser' # by default: :mandatory => false, :notnull => false end end
admin = client.query("SELECT FROM OUser WHERE name = 'admin'")[0] 1.upto(5) do |i| # insert link to admin only to first two client.command "INSERT INTO #{CLASS} (prop1, prop2, users) VALUES (#{i}, 'text#{i}', [#{admin['@rid'] if i<3}])" end
puts client.query "SELECT FROM #{CLASS}" => {"@type"=>"d", "@rid"=>"#6:0", "@version"=>0, "@class"=>"myclass", "prop1"=>1, "prop2"=>"text1", "users"=>["#4:0"]} => {"@type"=>"d", "@rid"=>"#6:1", "@version"=>0, "@class"=>"myclass", "prop1"=>2, "prop2"=>"text2", "users"=>["#4:0"]} => {"@type"=>"d", "@rid"=>"#6:2", "@version"=>0, "@class"=>"myclass", "prop1"=>3, "prop2"=>"text3", "users"=>[]} => {"@type"=>"d", "@rid"=>"#6:3", "@version"=>0, "@class"=>"myclass", "prop1"=>4, "prop2"=>"text4", "users"=>[]} => {"@type"=>"d", "@rid"=>"#6:4", "@version"=>0, "@class"=>"myclass", "prop1"=>5, "prop2"=>"text5", "users"=>[]}
puts client.query "SELECT count(*) FROM #{CLASS}" => {"@type"=>"d", "@version"=>0, "count"=>5, "@fieldTypes"=>"count=l"}
puts client.query "SELECT max(prop1) FROM #{CLASS}" => {"@type"=>"d", "@version"=>0, "max"=>5}
puts client.query "TRAVERSE any() FROM (SELECT FROM #{CLASS} WHERE prop1 = 1)" => {"@type"=>"d", "@rid"=>"#6:0", "@version"=>0, "@class"=>"myclass", "prop1"=>1, "prop2"=>"text1", "users"=>["#4:0"]} => {"@type"=>"d", "@rid"=>"#4:0", "@version"=>0, "@class"=>"OUser", "name"=>"admin", "password"=>"{SHA-256}8C6976E5B5410415BDE908BD4DEE15DFB167A9C873FC4BB8A81F6F2AB448A918", "status"=>"ACTIVE", "roles"=>["#3:0"]} => {"@type"=>"d", "@rid"=>"#3:0", "@version"=>0, "@class"=>"ORole", "name"=>"admin", "mode"=>1, "rules"=>{}, "@fieldTypes"=>"mode=b"}
client.drop_class CLASS client.disconnect => ["401 Unauthorized: Logged out", 401]
== INSTALL
sudo gem install orientdb4r
- gem published on http://rubygems.org/gems/orientdb4r
=== Important Upgrade Notice
- see +changelog.txt+
== FEATURES/PROBLEMS
- Supports only REST API right now
== REQUIREMENTS
- Ruby 1.9.x+
- OrientDB 1.0.x-1.3.x for v0.3.x
- OrientDB 1.4.0+ for v0.4.x
- OrientDB 1.6.0+ for v0.5.x
== TESTS
cd /path/to/repository bundle exec rake db:setup4test # to create the temp DB which doesn't seem to be a default since v1.5 bundle exec rake test
Make sure before starting the tests:
- database server is running on localhost:2480
- there is a root account with username=root and password=root; if your password is different, specify it with an
ORIENTDB_ROOT_PASSenvironment variable
== AUTHOR
- vaclav.sykora@gmail.com
- https://plus.google.com/115674031373998885915
== LICENSE
- Apache License, Version 2.0, http://www.apache.org/licenses/
- see LICENSE file for more details...
== CONTRIBUTING
- Fork it ( https://github.com/veny/orientdb4r/fork )
- Create your feature branch ( <tt>git checkout -b my-new-feature</tt> )
- Commit your changes ( <tt>git commit -am 'Add some feature'</tt> )
- Push to the branch ( <tt>git push origin my-new-feature</tt> )
- Create a new Pull Request
Related Skills
node-connect
352.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
