Experimental CouchDB wrapper
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
spec
.gitignore
Gemfile
Guardfile
LICENSE.txt
README.rdoc
Rakefile
upholstery.gemspec

README.rdoc

Upholstery

Mostly an experiment to learn about CouchDB, Upholstery provides a minimal wrapper around CouchDB's RESTful API.

Installation

Add this line to your application's Gemfile:

gem 'upholstery'

And then execute:

$ bundle

Or install it yourself as:

$ gem install upholstery

Usage

Connection

Establish the connection parameters with:

Upholstery::Base.establish_connection host: 'localhost', port: 5984, login: 'user', pass: 's3cr3t'

Database

To create a database:

db = Upholstery::Database.create('mydatabase')

To access an existing database:

db = Upholstery::Database.find('mydatabase')

To read attributes of a database:

puts db.db_name

To destroy a database:

db.destroy

Document

To create a document:

document = db.create(id: 'my-blog-post', title: 'My Blog Post', body: 'lorem ipsum...')

To find a document:

document = db.find('my-blog-post')

To read attributes of a document:

puts document.title

Temporary Views

To create a temporary view:

view = db.map('function(doc) { emit(doc.published_at, doc); }')

To access that view:

posts_by_date = view.all

To count the posts:

count = view.reduce('_count').first.value

Contributing

  1. Fork it ( github.com/sbfaulkner/upholstery/fork )

  2. Create your feature branch (`git checkout -b my-new-feature`)

  3. Commit your changes (`git commit -am 'Add some feature'`)

  4. Push to the branch (`git push origin my-new-feature`)

  5. Create a new Pull Request

License

Upholstery is released under the [MIT License](www.opensource.org/licenses/MIT).