Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A minimalist CouchDB client in ruby
Ruby Other
Failed to load latest commit information.
examples/word_count Use _doc suffix in examples for delete and save
lib Fixing issue #84 with short design doc names
spec
utils s/localhost/127.0.0.1/
.gitignore Ignoring .rvmrc
.rspec Updating spec, still lots of work to do
.travis.yml Adding rbx, to test out, and fixing jruby spec issue
Gemfile Run specs over ruby 2.0.0
LICENSE added apache license
README.md Clearing the distinction between direct calls, and reusable API
Rakefile Change the way we are running the specs. This way is more common.
THANKS.md Adding Sam and Will to Thanks.md
VERSION Fixing base64 attachment re-encoding issue #37
couchrest.gemspec Fixing authentication issue, oops
history.txt Fixing base64 attachment re-encoding issue #37
init.rb Add init.rb for easy usage as a Rails plugin (Makes for easy submodul…

README.md

CouchRest: CouchDB, close to the metal

Build Status

CouchRest wraps CouchDB's HTTP API using persistent connections with the HTTPClient gem managing servers, databases, and JSON document serialization using CouchDB's API endpoints so you don't have to.

CouchRest is designed to provide a simple base for application and framework-specific object oriented APIs. CouchRest is Object-Mapper agnostic, the JSON objects provided by CouchDB are parsed and returned as Document objects providing a simple Hash-like interface.

For more complete modelling support based on ActiveModel, please checkout CouchRest's sister project: CouchRest Model.

CouchDB Version

Tested on latest stable release (1.6.X), but should work on older versions above 1.0. Also known to work on Cloudant.

Install

$ sudo gem install couchrest

Basic Usage

Getting started with CouchRest is easy. You can send requests directly to a URL using a RestClient-like interface:

CouchRest.put("http://localhost:5984/testdb/doc", 'name' => 'test', 'date' => Date.current)

Or use the lean server and database orientated API to take advantage of persistent and reusable connections:

server = CouchRest.new           # assumes localhost by default!
db = server.database!('testdb')  # create db if it doesn't already exist

# Save a document, with ID
db.save_doc('_id' => 'doc', 'name' => 'test', 'date' => Date.current)

# Fetch doc
doc = db.get('doc')
doc.inspect # #<CouchRest::Document _id: "doc", _rev: "1-defa304b36f9b3ef3ed606cc45d02fe2", name: "test", date: "2015-07-13">

# Delete
db.delete_doc(doc)

Running the Specs

The most complete documentation is the spec/ directory. To validate your CouchRest install, from the project root directory use bundler to install the dependencies and then run the tests:

$ bundle install
$ bundle exec rake

To date, the couchrest specs have been shown to run on:

  • MRI Ruby 1.9.3 and later
  • JRuby 1.7.19
  • Rubinius 2.5.7

See the Travis Build status for more details.

Docs

Changes history: history.txt

API: http://rdoc.info/projects/couchrest/couchrest

Check the wiki for documentation and examples http://wiki.github.com/couchrest/couchrest

Contact

Please post bugs, suggestions and patches to the bug tracker at http://github.com/couchrest/couchrest/issues.

Follow us on Twitter: http://twitter.com/couchrest

Also, check https://twitter.com/search?q=couchrest

Something went wrong with that request. Please try again.