Coder Social home page Coder Social logo

softmotions / ejdb-ruby Goto Github PK

View Code? Open in Web Editor NEW
3.0 11.0 2.0 260 KB

Project archived in favor of ejdb2. Ruby binding for EJDB database engine

Home Page: http://ejdb.org

License: GNU Lesser General Public License v2.1

Makefile 0.55% Ruby 24.90% C 74.54%

ejdb-ruby's Introduction

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

ejdb-ruby's People

Contributors

adamansky avatar fyudanov avatar tyutyunkov avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ejdb-ruby's Issues

find is not working

I've successfully installed the ejdb ruby bindings according to the installation guide.
Creating a new database/collection works, but when I try to execute the "One snippet intro" the following exception is raised when it comes to find the data:

results = jb.find("parrots", {"likes" => "toys"}, {"$orderby" => {"name" => 1}})
TypeError: wrong argument type Hash (expected Data)

The same exception is raised with find_one

Here's my setup:

  • Mac OS X 10.8.5
  • Ruby 2.0 p247
  • Installed ejdb via homebrew (v1.1.24)

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.