Skip to content

@edbond /gist:136563
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
require 'rubygems'
require 'couchrest'
db = CouchRest.database!("http://127.0.0.1:5984/loans")
db.recreate!
doc1 = db.save_doc({:loan_amount => 40000, :loan_period => 4})
doc2 = db.save_doc({:loan_amount => 20000, :loan_period => 2})
doc3 = db.save_doc({:loan_amount => 50000, :loan_period => 9})
db.save_doc({
"_id" => "_design/loans",
:views => {
:test => {
:map => "function(doc) { emit([doc.loan_amount, doc.loan_period], doc) }"
}
}
})
puts db.view("loans/test", {:startkey => [30000, 5], :endkey => [{},{}]})['rows'].inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.