views:

548

answers:

2

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.

A: 

Sounds like you need Berkeley DB. It does everything you list except for map/reduce.

Bill Karwin
+2  A: 

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

jgre
Hm, yes seems that this is what I need. I will definetly try this. Thank you very much!
Mike Chaliy