Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedded analog of CouchDB, same as sqlite for SQL Server

I like an idea of document oriented databases like CouchDB. I am looking for simple analog.

My requirements is just:

  1. persistance storage for schema less data;
  2. some simple in-proc quering;
  3. good to have transactions and versioning;
  4. ruby API;
  5. map/reduce is aslo good to have;
  6. should work on shared hosting

What I do not need is REST/HTTP interfaces (I will use it in-proc). Also I do not need all scalability stuff.

like image 977
Mike Chaliy Avatar asked Oct 15 '22 14:10

Mike Chaliy


1 Answers

A very simple solution would be PStore from Ruby's Standard Library. It should meet almost all your requirements:

  1. PStore stores Ruby object hierarchies in files, so you can easily use the Hash-like structures, you would have in CouchDB
  2. You can access the contents of the PStore with a simple API
  3. It has transactions, but no versions as far as I know
  4. yes
  5. You can use Ruby's map and inject functions
  6. All you need is access to the file system

Example:

Insert data into the store:

require 'pstore'
store = PStore.new("/tmp/store")
store.transaction do
  store["products"] = [{:name => "Test", :price => 100}
                       {:name => "Bla", :price => 120}
                       {:name => "Oink", :price => 300}]
end

Query the sum of the prices of all products:

store.transaction do
  store['products'].map {|p| p[:price]}.inject {|sum, p| sum + p}
end

More information in this blog-post

like image 189
jgre Avatar answered Oct 18 '22 12:10

jgre