Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View gist:136563
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
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.