#### {% title "CouchDB – Ruby" %} # CouchDB – Ruby ## Korzystamy z gemu *rest-client* Przykład z Wiki: [collation](http://wiki.apache.org/couchdb/View_collation): :::ruby # file: collseq.rb require 'rubygems' require 'restclient' require 'json' DB="http://127.0.0.1:5984/collator" RestClient.delete DB rescue nil RestClient.put "#{DB}","" (32..126).each do |c| RestClient.put "#{DB}/#{c.to_s(16)}", {"x"=>c.chr}.to_json end RestClient.put "#{DB}/_design/test", < "Włodek", "login" => "wbzyl", "wiek" => "18" } result = db.save_doc(attr) Dalej :::ruby result['id'] record = db.get(result['id']) record['_rev'] record['login'] = 'matwb' result = db.save_doc(record) record = db.get(result['id']) db.delete_doc(record) Zob. [Contacts](http://gist.github.com/112109), [blog J. P. Wood’a](http://johnpwood.net/tag/couchrest/), [Rails Wiki: CouchDB](http://wiki.rubyonrails.org/database-support/couchdb).