From d3a7717363e61e1f13e7358127b188e2ac95d0b7 Mon Sep 17 00:00:00 2001 From: Chris Anderson Date: Thu, 16 Apr 2009 12:20:17 -0700 Subject: [PATCH 1/2] version support note --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6315426..6c68ad9 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ to CouchDB's API endpoints so you don't have to. CouchRest is designed to make a simple base for application and framework-specific object oriented APIs. CouchRest is Object-Mapper agnostic, the parsed JSON it returns from CouchDB shows up as subclasses of Ruby's Hash. Naked JSON, just as it was mean to be. +Note: CouchRest only support CouchDB 0.9.0 or newer. + ## Easy Install Easy Install is moving to RubyForge, heads up for the gem. From 8363aa629837d333d04373523fdcc10b392fb368 Mon Sep 17 00:00:00 2001 From: Chris Anderson Date: Fri, 8 May 2009 19:00:39 -0700 Subject: [PATCH 2/2] added bulk_load macro --- lib/couchrest/core/database.rb | 5 +++++ spec/couchrest/core/database_spec.rb | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/couchrest/core/database.rb b/lib/couchrest/core/database.rb index 060c124..90c4828 100644 --- a/lib/couchrest/core/database.rb +++ b/lib/couchrest/core/database.rb @@ -44,6 +44,11 @@ module CouchRest end end + # load a set of documents by passing an array of ids + def get_bulk(ids) + documents(:keys => ids, :include_docs => true) + end + # POST a temporary view function to CouchDB for querying. This is not # recommended, as you don't get any performance benefit from CouchDB's # materialized views. Can be quite slow on large databases. diff --git a/spec/couchrest/core/database_spec.rb b/spec/couchrest/core/database_spec.rb index f5565b0..985ebf9 100644 --- a/spec/couchrest/core/database_spec.rb +++ b/spec/couchrest/core/database_spec.rb @@ -599,6 +599,11 @@ describe CouchRest::Database do ds = @db.documents(:startkey => 'doc0', :endkey => 'doc3', :include_docs => true) ds['rows'][0]['doc']['another'].should == "doc" end + it "should have the bulk_load macro" do + rs = @db.bulk_load ["doc0", "doc7"] + rs['rows'].length.should == 2 + ds['rows'][0]['doc']['another'].should == "doc" + end end