Embedded analog of CouchDB, same as sqlite for SQL Server
-
10-07-2019 - |
Question
I like an idea of document oriented databases like CouchDB. I am looking for simple analog.
My requirements is just:
- persistance storage for schema less data;
- some simple in-proc quering;
- good to have transactions and versioning;
- ruby API;
- map/reduce is aslo good to have;
- 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.
Solution
A very simple solution would be PStore from Ruby's Standard Library. It should meet almost all your requirements:
- PStore stores Ruby object hierarchies in files, so you can easily use the Hash-like structures, you would have in CouchDB
- You can access the contents of the PStore with a simple API
- It has transactions, but no versions as far as I know
- yes
- You can use Ruby's map and inject functions
- 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
OTHER TIPS
Sounds like you need Berkeley DB. It does everything you list except for map/reduce.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow