orientdb4r - Ruby binding for Orient DB

A Ruby client for the NoSQL Graph/Document database Orient DB (orientdb.org).

USAGE

see Wiki page for more sample at github.com/veny/orientdb4r/wiki

require 'orientdb4r'

CLASS = 'myclass'

client = Orientdb4r.client  # equivalent for :host => 'localhost', :port => 2480, :ssl => false

client.connect :database => 'temp', :user => 'admin', :password => 'admin'

client.create_class(CLASS) do |c|
  c.property 'prop1', :integer
  c.property 'prop2', :string, :mandatory => true, :notnull => :true, :min => 1, :max => 99
end

1.upto(10) { |i| client.command "INSERT INTO #{CLASS} (prop1, prop2) VALUES (#{i}, 'string#{i}')" }

puts client.query "SELECT FROM #{CLASS}"
> {"@type"=>"d", "@rid"=>"#6:0", "@version"=>0, "@class"=>"testing", "prop1"=>1, "prop2"=>"string1"}
> {"@type"=>"d", "@rid"=>"#6:1", "@version"=>0, "@class"=>"testing", "prop1"=>2, "prop2"=>"string2"}
> {"@type"=>"d", "@rid"=>"#6:2", "@version"=>0, "@class"=>"testing", "prop1"=>3, "prop2"=>"string3"}
> {"@type"=>"d", "@rid"=>"#6:3", "@version"=>0, "@class"=>"testing", "prop1"=>4, "prop2"=>"string4"}
> {"@type"=>"d", "@rid"=>"#6:4", "@version"=>0, "@class"=>"testing", "prop1"=>5, "prop2"=>"string5"}
> {"@type"=>"d", "@rid"=>"#6:5", "@version"=>0, "@class"=>"testing", "prop1"=>6, "prop2"=>"string6"}
> {"@type"=>"d", "@rid"=>"#6:6", "@version"=>0, "@class"=>"testing", "prop1"=>7, "prop2"=>"string7"}
> {"@type"=>"d", "@rid"=>"#6:7", "@version"=>0, "@class"=>"testing", "prop1"=>8, "prop2"=>"string8"}
> {"@type"=>"d", "@rid"=>"#6:8", "@version"=>0, "@class"=>"testing", "prop1"=>9, "prop2"=>"string9"}
> {"@type"=>"d", "@rid"=>"#6:9", "@version"=>0, "@class"=>"testing", "prop1"=>10, "prop2"=>"string10"}
puts client.query "SELECT count(*) FROM #{CLASS}"
> {"@type"=>"d", "@version"=>0, "count"=>10, "@fieldTypes"=>"count=l"}
puts client.query "SELECT max(prop1) FROM #{CLASS}"
> {"@type"=>"d", "@version"=>0, "max"=>10}
puts client.query "SELECT FROM #{CLASS} WHERE prop2 LIKE '%10'"
> {"@type"=>"d", "@rid"=>"#6:9", "@version"=>0, "@class"=>"testing", "prop1"=>10, "prop2"=>"string10"}

client.drop_class CLASS
client.disconnect

INSTALL

> sudo gem install orientdb4r

FEATURES/PROBLEMS

  • Supports only REST API right now

REQUIREMENTS

Tested on

  • Ruby 1.9.3

  • OrientDB 1.0.0

AUTHOR

LICENSE