Assumption: you have couchapp and couchDB installed, see this post
Disclaimer: While I've read a bunch about couch's background, I have yet to setup any apps. Today's challenge is to set one up in 60 seconds and blog about it (in a much longer time).
step one
Clone somebody else's app to see the structure
I cloned Tyler's pic app, from CouchOne. I just realized Tyler may enjoy Dead Can Dance as well.
couchapp clone http://victusfate.couchone.com/pics/_design/pic pic
If you point clone to a couchapp it grabs a file tree structure that looks like this:
. |-_attachments |---style |-evently |---items |-----_changes |---profile |-----profileReady |-------selectors |---------form |-lists |-shows |-template |-updates |-vendor |---couchapp |-----_attachments |-----docs |-----evently |-------account |---------loggedIn |---------loggedOut |---------loginForm |-----------selectors |-------------form |---------signupForm |-----------selectors |-------------form |-------docs |---------index |---------topic |-----------edit |-------------_init |---------------selectors |-----------------a.edit |-----------------a.run |-------profile |---------loggedOut |---------noProfile |-----------selectors |-------------form |---------profileReady |-----lib |-views |---main |---recent-items
That's more than I want to care about off the bat. Let's see if there's someplace I can stick all my photos without thinking.
The important aspects of accessing CouchDB are well articulated by Noah Slater's definitive guide (I now have the pdf, Kindle version, and iOS app). You can complain about your pain points directly to Noah here at his mailing list but be nice and RTFM first. My immediate difficulties included:
- having to manually check all the document members accessed in an if block for any map functions (think keyword searching a B Tree)
function(doc) { var store, price, value; if (doc.item && doc.prices) { for (store in doc.prices) { price = doc.prices[store]; value = [doc.item, store]; emit(price, value); } } }
I'm all out of time at the moment but you can at least see Tyler's variant of the couchapp and I'll get back to tweaking my local version and documenting later. Looking forward to attaching image files later tonight.