Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It looks like the CouchRest github <a href="https://github.com/couchrest/couchrest/wiki/Usage-Overview" rel="nofollow">UsageOverview wiki page</a> has some basic examples, in the "Attachments" section:</p> <pre class="lang-rb prettyprint-override"><code>contents = "&lt;html&gt;&lt;body&gt;If you're happy and you know it, clap your hands.&lt;/body&gt;&lt;/html&gt;" @db.put_attachment(doc, "happy.html", contents, :content_type =&gt; "text/html") # =&gt; {"ok"=&gt;true, "id"=&gt;"e0d70033da0fad3707fed320bd7e0770", "rev"=&gt;"2-20635570c75e8b20f7a73fd1538f318d"} # NOTE: The document is not updated automatically with the attachment information pp doc.to_hash # {"_id"=&gt;"e0d70033da0fad3707fed320bd7e0770", # "_rev"=&gt;"1-cbb61d1f90f7c01b273737702265b6c8", # "key"=&gt;"value", # "another key"=&gt;"another value"} # If you try to fetch the attachment without getting the new state of the document, you will fail @db.fetch_attachment(doc, "happy.html") # =&gt; RestClient::ResourceNotFound: 404 Resource Not Found: {"error":"not_found","reason":"Document is missing attachment"} doc = @db.get(doc["_id"]) pp doc.to_hash # {"_id"=&gt;"e0d70033da0fad3707fed320bd7e0770", # "_rev"=&gt;"2-20635570c75e8b20f7a73fd1538f318d", # "key"=&gt;"value", # "another key"=&gt;"another value", # "_attachments"=&gt; # {"happy.html"=&gt; # {"content_type"=&gt;"text/html", # "revpos"=&gt;2, # "digest"=&gt;"md5-q3MreM1aJgfSLHGrJLdg4g==", # "length"=&gt;75, # "stub"=&gt;true}}} @db.fetch_attachment(doc, "happy.html") =&gt; "&lt;html&gt;&lt;body&gt;If you're happy and you know it, clap your hands.&lt;/body&gt;&lt;/html&gt;" </code></pre> <p>See the rest of the page for more examples (including deleting attachments).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload