<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Assertion Through Structure &#187; couchdb</title>
	<atom:link href="http://www.blog.dannygagne.com/archives/category/couchdb/feed" rel="self" type="application/rss+xml" />
	<link>http://www.blog.dannygagne.com</link>
	<description>Manipulating the future one day at a time</description>
	<lastBuildDate>Sun, 15 Jan 2012 16:14:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>JChris&#039;s Presentation on CouchDB</title>
		<link>http://www.blog.dannygagne.com/archives/171</link>
		<comments>http://www.blog.dannygagne.com/archives/171#comments</comments>
		<pubDate>Mon, 28 Sep 2009 00:22:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[couchdb]]></category>

		<guid isPermaLink="false">http://www.blog.dannygagne.com/?p=171</guid>
		<description><![CDATA[I've been using CouchDB for close to a year now, but I took some notes for those not familiar with it. Link to the slides: http://www.slideshare.net/jchrisa/couchdb-local-web-platform Some Notes: CouchDB is a Local Web Platform - run the application close to the user achieved through replication. Offline By Default http://jacobian.org/writing/of-the-web/ One of the apps referenced: http://c.ixxr.net/swinger/_design/swinger/index.html#/ [...]]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/ESDBM9-U804&amp;hl=en&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/ESDBM9-U804&amp;hl=en&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>I've been using CouchDB for close to a year now, but I took some notes for those not familiar with it.</p>
<p>Link to the slides: http://www.slideshare.net/jchrisa/couchdb-local-web-platform</p>
<p>Some Notes:</p>
<ol>
<li>CouchDB is a Local Web Platform - run the application close to the user achieved through replication.</li>
<li>Offline By Default</li>
<li><a href="http://jacobian.org/writing/of-the-web/" onclick="pageTracker._trackPageview('/outgoing/jacobian.org/writing/of-the-web/?referer=');">http://jacobian.org/writing/of-the-web/</a></li>
<li>
<ul>
<li>One of the apps referenced:<a href="http://c.ixxr.net/swinger/_design/swinger/index.html#/" onclick="pageTracker._trackPageview('/outgoing/c.ixxr.net/swinger/_design/swinger/index.html_/?referer=');"> http://c.ixxr.net/swinger/_design/swinger/index.html#/</a></li>
<li>And  a neat presentation on Sammy.js:  <a href="http://c.ixxr.net/swinger/_design/swinger/index.html#/preso/jqcon_09/display/1" onclick="pageTracker._trackPageview('/outgoing/c.ixxr.net/swinger/_design/swinger/index.html_/preso/jqcon_09/display/1?referer=');">http://c.ixxr.net/swinger/_design/swinger/index.html#/preso/jqcon_09/display/1</a></li>
</ul>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.dannygagne.com/archives/171/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exposing CouchDB to the World</title>
		<link>http://www.blog.dannygagne.com/archives/75</link>
		<comments>http://www.blog.dannygagne.com/archives/75#comments</comments>
		<pubDate>Fri, 29 May 2009 11:38:42 +0000</pubDate>
		<dc:creator>danny</dc:creator>
				<category><![CDATA[couchdb]]></category>

		<guid isPermaLink="false">http://www.blog.dannygagne.com/?p=75</guid>
		<description><![CDATA[To allow non-local connections to couchdb is quite easy. To allow non local access, modify /usr/local/etc/couchdb/default.ini so that bind_address = 0.0.0.0]]></description>
			<content:encoded><![CDATA[<p>To allow non-local connections to couchdb is quite easy.</p>
<p>To allow non local access, modify </p>
<p><code><br />
/usr/local/etc/couchdb/default.ini<br />
</code></p>
<p>so that<br />
<code><br />
bind_address = 0.0.0.0<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.dannygagne.com/archives/75/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CouchDB &amp; CouchApp Managing Design Documents</title>
		<link>http://www.blog.dannygagne.com/archives/43</link>
		<comments>http://www.blog.dannygagne.com/archives/43#comments</comments>
		<pubDate>Mon, 11 May 2009 08:06:55 +0000</pubDate>
		<dc:creator>danny</dc:creator>
				<category><![CDATA[couchdb]]></category>
		<category><![CDATA[riot]]></category>

		<guid isPermaLink="false">http://www.blog.dannygagne.com/?p=43</guid>
		<description><![CDATA[I've been working with CouchDB and I was never really happy with how I was managing/version controlling my design documents.  Luckily, I read about CouchApp -- I had initially thought it was a tool for developing CouchDB hosted appilcations, but now know that it can be used to at a very basic level to make [...]]]></description>
			<content:encoded><![CDATA[<p>I've been working with <a href="http://couchdb.apache.org/" onclick="pageTracker._trackPageview('/outgoing/couchdb.apache.org/?referer=');">CouchDB</a> and I was never really happy with how I was managing/version controlling my design documents.  Luckily, I read about <a href="http://github.com/jchris/couchapp/tree/master" onclick="pageTracker._trackPageview('/outgoing/github.com/jchris/couchapp/tree/master?referer=');">CouchApp</a> -- I had initially thought it was a tool for developing CouchDB hosted appilcations, but now know that it can be used to at a very basic level to make it easy to control my desgin documents.  Here are a few notes that might make it easy for others to get started; I'm still learning this tool, so this may not be the optimal procedure (also, I'm not using any of the advanced features of CouchApp [e.g. macros], but will in the future).</p>
<p>There are two ways of using CouchApp  to push design documents to CouchDb: 1.  Generating the design document from multiple files (preferred), and 2. Generating the views from a single JSON file.</p>
<p><strong>Generating the Design Document from its Component Pieces<br />
</strong></p>
<ol>
<li>Install CouchDB &amp; CouchApp - Both are easy to install and well documented, so need for any additional notes.</li>
<li>The directory structure used is used to hold the atomic pieces of the design document and should have a structure as follows:
<ul>
<li>{myapp}  - app directory</li>
<li>{myapp}/{sampledesign} -- design document name</li>
<li>{myapp}/{sampledesign}/views -- directory that holds views</li>
<li>{myapp}/{sampledesign}/views/{viewname}/ -- view name</li>
<li>{myapp}/{sampledesign}/views/{viewname}/map.js -- map function</li>
<li>{myapp}/{sampledesign}/views/{viewname}/reduce.js -- reduce function</li>
</ul>
<p>We create a directory for the application<em> {myapp}</em>, we  then create a directory to hold our design document <em>{sampledesign}</em>, and last we create a directory for our view<em> {viewname}</em>.  Each view must contain one map.js file, and can (optional) contain one reduce.js file.</li>
<li>In this example we're only going to create a map function, so map.js should look like:

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">        <span style="color: #006600; font-style: italic;">//This is a simple function that doesn't do anything</span>
        <span style="color: #006600; font-style: italic;">//useful, but will work on all CouchDB databases.</span>
        <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>doc<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
           emit<span style="color: #009900;">&#40;</span>doc._id<span style="color: #339933;">,</span> doc<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span></pre></div></div>

</li>
<li>To generate the design document and push it into CouchDB: Go to the <em>{myapp} </em>directory run the following command (for this example assume: {myapp} = myapp and {sampledesing} = mydesigndoc ):
<p style="text-align: center;"><strong>couchapp push mydesigndoc http://127.0.0.1:5984/myapp </strong></p>
</li>
<li>To view the generate design document you can go to  <a href="http://localhost:5984/_utils/document.html?myapp/_design/mydesigndoc#source" onclick="pageTracker._trackPageview('/outgoing/localhost_5984/_utils/document.html?myapp/_design/mydesigndoc_source&amp;referer=');">http://localhost:5984/_utils/document.html?myapp/_design/mydesigndoc#source</a> (the following url is for a db named <em>myapp</em> with a design document named<em> mydesigndoc</em>)</li>
</ol>
<p>And that's all there is to it.  You can develop and version control the design documents.</p>
<p><strong>Alternate: Generating the views from a single JSON file.</strong></p>
<ol style="text-align: left;">
<li>Install CouchDB &amp; CouchApp - Both are easy to install and well documented, so need for any additional notes.</li>
<li>Create a directory to store the design documents: "myapp/_design"  (this directory can be anything)</li>
<li>Create a directory for each design document: "myapp/_desgin/design_document"</li>
<li>Inside the design document create a JSON file named views (views.json) : "myapp/_design/design_document/views.json"</li>
<li>The contents of thee view document should be a JSON document containing view objects with map and reduce functions. For example, see the code listing below we have the view test with a map function.  Note: This is a useless view, but it will work on any CouchDB database.

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
   <span style="color: #3366CC;">&quot;views&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #3366CC;">&quot;test&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #3366CC;">&quot;map&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;function(doc) {<span style="color: #000099; font-weight: bold;">\n</span>    emit(doc._id, doc);<span style="color: #000099; font-weight: bold;">\n</span>}<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
       <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</li>
<li>From the "_design" directory run the following command:
<p style="text-align: center;"><em><strong> </strong></em><strong>couchapp push {desgin_document_dir} http://127.0.0.1:5984/{<em>dbname</em>} </strong></p>
<p style="text-align: left;">where {dbname} is the name of your db and {design_document_dir} is the name of the design document directory , so if my database was named: "myapp"  and the design document dir was named: "sampledesign" it would look like:</p>
<p style="text-align: center;"><strong>couchapp push sampledesign http://127.0.0.1:5984/myapp </strong></p>
<p style="text-align: left;">Note: If you are unsure of what the view json structure is you can create your views using <a href="http://couchdb.apache.org/screenshots.html" onclick="pageTracker._trackPageview('/outgoing/couchdb.apache.org/screenshots.html?referer=');">Futon</a> which is installed at: <a href="http://localhost:5984/_utils/" onclick="pageTracker._trackPageview('/outgoing/localhost_5984/_utils/?referer=');">http://localhost:5984/_utils/</a> by creating a temporary view, saving it, and then navigating to the design document it created.  <a href="http://localhost:5984/_utils/document.html?myapp/_design/sampledesign#source" onclick="pageTracker._trackPageview('/outgoing/localhost_5984/_utils/document.html?myapp/_design/sampledesign_source&amp;referer=');">http://localhost:5984/_utils/document.html?myapp/_design/sampledesign#source</a> (the following url is for a db named <em>myapp</em> with a design document named<em> sampledesign</em>)</p>
</li>
</ol>
<p>After following those steps you can easily push json documents to couchdb and use whatever version controll system that you'd like; however, there is a better way of laying out the files.</p>
<p style="text-align: left;">So there you have it, a quick introduction to the two ways of using CouchApp to manage CouchDB Documents.<strong><br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.dannygagne.com/archives/43/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

