Class: CouchRest::Database
- Inherits:
-
Object
- Object
- CouchRest::Database
- Defined in:
- lib/couchrest/extensions.rb
Instance Method Summary collapse
-
#list(list_name, view_name, doc_name, params = {}) ⇒ Object
Query a CouchDB view as defined by a
_design
document. -
#put_attachment(doc, name, file, options = {}) ⇒ Object
PUT an attachment directly to CouchDB.
Instance Method Details
#list(list_name, view_name, doc_name, params = {}) ⇒ Object
Query a CouchDB view as defined by a _design
document. Accepts paramaters as described in wiki.apache.org/couchdb/HttpViewApi /db/_design/examples/_list/index-posts/posts-by-date
7 8 9 10 11 12 13 |
# File 'lib/couchrest/extensions.rb', line 7 def list(list_name, view_name, doc_name, params = {}) url = CouchRest.paramify_url "#{@root}/_design/#{doc_name}/_list/#{list_name}/#{view_name}", params response = RestClient.get(url) JSON.parse(response) rescue response end |
#put_attachment(doc, name, file, options = {}) ⇒ Object
PUT an attachment directly to CouchDB
16 17 18 19 20 |
# File 'lib/couchrest/extensions.rb', line 16 def (doc, name, file, = {}) docid = escape_docid(doc['_id']) uri = (doc, name) JSON.parse(HttpAbstraction.put(uri, file, )) end |