methodmissing / ejdb-ruby

Ruby binding for EJDB database engine

Home Page:http://ejdb.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Embedded JSON database library Ruby binding

Installation

Required tools/system libraries:

(A) Installing directly from sources

git clone https://github.com/Softmotions/ejdb-ruby.git
cd ./ejdb-ruby
make  
sudo make install

One snippet intro

require "rbejdb"

#Open zoo DB
jb = EJDB.open("zoo", EJDB::DEFAULT_OPEN_MODE | EJDB::JBOTRUNC)

parrot1 = {
    "name" => "Grenny",
    "type" => "African Grey",
    "male" => true,
    "age" => 1,
    "birthdate" => Time.now,
    "likes" => ["green color", "night", "toys"],
    "extra1" => nil
}
parrot2 = {
    "name" => "Bounty",
    "type" => "Cockatoo",
    "male" => false,
    "age" => 15,
    "birthdate" => Time.now,
    "likes" => ["sugar cane"],
    "extra1" => nil
}

jb.save("parrots", parrot1, parrot2)
puts "Grenny OID: #{parrot1["_id"]}"
puts "Bounty OID: #{parrot2["_id"]}"

results = jb.find("parrots", {"likes" => "toys"}, {"$orderby" => {"name" => 1}})

puts "Found #{results.count} parrots"

results.each { |res|
  puts "#{res['name']} likes toys!"
}

results.close #It's not mandatory to close cursor explicitly
jb.close #Close the database

About

Ruby binding for EJDB database engine

http://ejdb.org

License:GNU Lesser General Public License v2.1


Languages

Language:C 74.3%Language:Ruby 25.7%