fix temp_view -> slow_view stuff for couchdb trunk

This commit is contained in:
Matt Lyon 2009-01-04 23:00:59 -08:00
parent 71f5ea2a1b
commit e15581b1dd
2 changed files with 8 additions and 5 deletions

View file

@ -47,12 +47,15 @@ module CouchRest
# 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.
def temp_view funcs, params = {}
def slow_view funcs, params = {}
keys = params.delete(:keys)
funcs = funcs.merge({:keys => keys}) if keys
url = CouchRest.paramify_url "#{@root}/_temp_view", params
url = CouchRest.paramify_url "#{@root}/_slow_view", params
JSON.parse(RestClient.post(url, funcs.to_json, {"Content-Type" => 'application/json'}))
end
# backwards compatibility is a plus
alias :temp_view :slow_view
# Query a CouchDB view as defined by a <tt>_design</tt> document. Accepts
# paramaters as described in http://wiki.apache.org/couchdb/HttpViewApi

View file

@ -42,9 +42,9 @@ describe CouchRest::Database do
describe "map/reduce query with _temp_view in Javascript" do
before(:each) do
@db.bulk_save([
{"beverage" => "beer", :limit => 4},
{"beverage" => "beer", :limit => 2},
{"beverage" => "tea", :limit => 3}
{"beverage" => "beer", :count => 4},
{"beverage" => "beer", :count => 2},
{"beverage" => "tea", :count => 3}
])
end
it "should return the result of the temporary function" do