fullstack_couchdb



fullstack_couchdb

1 0


fullstack_couchdb

Fullstack CouchDB Talk

On Github neshmi / fullstack_couchdb

CouchDB

A love/hate relationship explained

Oh hey, these are some notes. They'll be hidden in your presentation, but you can see them if you open the speaker notes window (hit 's' on your keyboard).

who am i?

Rubyist for Cultural Heritage

i am not...(unfortunately?)

Because I am a Husband

but i do <3 code

And I was once a preacher...

where it all began...

pragmatism = I'm lazy

and it progressed...

and then there were more

and still more...

CouchDB

When I first found out about CouchDB...

CouchDB

And the more I read...

CouchDB

And then I started working with Couch...

Let's Break it Down

A CouchDB Document

{
   "_id": "b4d45d962f2ddec91d1d434d280006bf",
   "_rev": "1-c442720ae4a92bbd2ee4945f68150a2f",
   "title": "CouchDB is so amazing",
   "body": "This is a post body",
   "date":"2013/06/30 18:04:11",
   "author": "Matthew Vincent"
}

Let's Break it Down

Revisions (Yay!!)

{
   "_id": "b4d45d962f2ddec91d1d434d280006bf",
   "_rev": "2-156b979c9d8fabc42ccace0e7a04a426",
   "title": "CouchDB is so amazing",
   "body": "This is a post body.  And now I've added another line.",
   "date":"2013/06/30 18:04:11",
   "author": "Matthew Vincent"
}

Map/reduce

CoffeeScript

(doc) ->
  if doc.title? and doc.date?
    emit doc.title, [doc.date, doc._id]

JavaScript

function(doc) {
  if(doc.title && doc.date) {
    emit(doc.title, [doc.date, doc._id]);
  }
}

results in:

{
   "_id": "_design/blog",
   "_rev": "1-67072284f987db058a4bcf02a57288a2",
   "language": "coffeescript",
   "views": {
       "title_date_id": {
           "map": "(doc) ->\n  if doc.title? and doc.date?\n    emit doc.title, [doc.date, doc._id]\n"
       }
   }
}

Map/reduce

CoffeeScript

(doc) ->
  if doc.title? and doc.date?
    emit doc.title, [doc.date, doc._id]

RESTful Query

GET /blog/_design/blog/_view/title_date_id

JSON Result

{"total_rows":3,"offset":0,"rows":[
{"id":"couchdb-is-so-amazing","key":"CouchDB is so amazing","value":["2013/06/30 18:04:11","couchdb-is-so-amazing"]},
{"id":"my-final-post","key":"My final post","value":["2013/08/30 18:04:11","my-final-post"]},
{"id":"yay-for-archaeology","key":"Yay for Archaeology!!","value":["2013/07/30 18:04:11","yay-for-archaeology"]}
]}

Archaeological heirarchy

Field (For example: B) Square (For example: 8K11) Locus (For example: 012) <-- Smallest unit of excavation

!!!

But with Couch, there is no table with a list of fields, squares or loci.

Something a bit more complex

An archaeological field sheet

{
   "_id": "05eedaeea89d4003355688d4762da8b5",
   "_rev": "1-eceefe359ab349fb3025b20363f9c383",
   "field": "B",
   "code": "035",
   "square": "7K91",
   "top_separation": "Average",
   "end_date": "2008-07-10",
   "stratigraphies": [
       {
           "related_locus": "B7K91:034",
           "is_related": "Cuts",
           "related": "Earth layer"
       },
       {
           "related_locus": "B7K91:033",
           "is_related": "Fill Loci",
           "related": "Earth layer"
       }
   ],
   "installation_description": {
       "nari_percent": "0",
       "orientation": "0",
       "stone_percent": "0",
       "limestone_percent": "0",
       "other_name": null,
       "stratigraphy_remarks": null,
       "upper_height": 0.34,
       "ceramic_quality_1": null,
       "ceramic_quality_2": null,
       "earth_percent": "100",
       "remarks": null,
       "bedrock_quality_1": null,
       "bedrock_quality_2": null,
       "plan_type": "Rectangular",
       "plaster_quality_1": null,
       "plaster_quality_2": null,
       "upper_width": 0.23
   },
   "reason": "Looser earth & slightly diff color",
   "artifacts": [
   ],
   "state": "approved",
   "designation": "FT around Wall 11",
   "draw_balks": null,
   "function": "FT for Wall 11",
   "sample_remarks": null,
   "couchrest-type": "Locus",
   "pails": [
   ],
   "balk": null,
   "locus_type": "Installation",
   "samples": [
   ],
   "bottom_separation": "Average",
   "sample_reason": null,
   "start_date": "2008-07-10",
   "stratigraphy_remarks": "Earlier than Wall 11",
   "supervisor": "G. Huffaker",
   "photos": [
   ],
   "cron_type": null,
   "age": "Late Iron 2/Persian",
   "created_at": "2010-07-05T16:06:05Z",
   "levels": [
       {
           "bottom_is_legacy": true,
           "burial": 0,
           "method_top": "T",
           "bottom_level": 912.04,
           "top_is_legacy": true,
           "top_level": 912.33,
           "method_bottom": null,
           "location": 6
       }
   ],
   "updated_at": "2010-07-31T09:44:21Z"
}

To Generate that list

Map:

function(doc){if (doc.field) emit(doc.field,doc.field);};

Reduce

function(keys,values){return true;};

RESTful Query

GET opendig-development/_design/OpenDigRails/_view/fields?group=true

JSON Result

{"rows":[
{"key":"A","value":true},
{"key":"B","value":true},
{"key":"C","value":true},
{"key":"D","value":true},
{"key":"E","value":true},
{"key":"F","value":true},
{"key":"G","value":true},
{"key":"H","value":true},
{"key":"K","value":true},
{"key":"L","value":true},
{"key":"M","value":true},
{"key":"N","value":true},
{"key":"R","value":true},
{"key":"S","value":true}
]}

Then...

Map:

function(doc){emit([doc.field, doc.square], doc.field);};

Reduce

function(keys,values){return true;};

RESTful Query

GET opendig-development/_design/OpenDigRails/_view/squares_by_field?group=true&startkey=["A"]&endkey=["A"]

JSON Result

{"rows":[

]}

It won't work unless...

RESTful Query

GET opendig-development/_design/OpenDigRails/_view/squares_by_field?group=true&startkey=["A"]&endkey=["A",{}]

OR

GET opendig-development/_design/OpenDigRails/_view/squares_by_field?group=true&startkey=["A"]&endkey=["A\uffff"]

JSON Result

{"rows":[
  {"key":["A","7J49"],"value":true},
  {"key":["A","7J59"],"value":true},
  {"key":["A","7J68"],"value":true},
  {"key":["A","7J69"],"value":true},
  {"key":["A","7J78"],"value":true},
  {"key":["A","7J79"],"value":true},
  {"key":["A","7K40"],"value":true},
  {"key":["A","7K41"],"value":true},
  {"key":["A","7K42"],"value":true},
  {"key":["A","7K50"],"value":true},
  {"key":["A","7K51"],"value":true},
  {"key":["A","7K52"],"value":true},
  {"key":["A","7K60"],"value":true},
  {"key":["A","7K61"],"value":true},
  {"key":["A","7K62"],"value":true},
  {"key":["A","7K70"],"value":true},
  {"key":["A","7K71"],"value":true},
  {"key":["A","7K72"],"value":true}
]}

Calling with a single key

Map

function(doc){emit(doc.field + doc.square + ':' + doc.code, doc);}

RESTful Query

GET opendig-development/_design/OpenDigRails/_view/locus?key="B8K11:037"

JSON Result

{"total_rows":3918,"offset":1541,"rows":[
{"id":"778d41ddabf2e4b20673f8af54748abd","key":"B8K11:037","value":{"_id":"778d41ddabf2e4b20673f8af54748abd","_rev":"1-884cae78b3d3024577138acdf2b2003a","field":"B","top_separation":"Clear","square":"8K11","architecture":"0","clean_locus":false,"end_date":"2008-07-09","sub_balks":null,"top_plan":"32,33","installation_description":{"other_percent":"0","plan_quality_1_other":null,"plan_quality_2_other":null,"type":"InstallationDescription","certain":null,"earth_quality_1":null,"earth_quality_2":null,"plan_quality_1":"None","plan_quality_2":null,"mud_quality_1":null,"mud_quality_2":null,"lower_height":0.17999999999999999334,"nari_quality_1":null,"nari_quality_2":null,"other_quality_1":null,"other_quality_2":null,"ceramic_percent":"0","length":2.2999999999999998224,"mudbrick_quality_1":null,"mudbrick_quality_2":null,"plan_remarks":null,"plaster_percent":"0","probable1":"Bench","stone_quality_1":null,"stone_quality_2":null,"lime_quality_1":"Hard","lime_quality_2":null,"lining":"None","lower_width":0.47999999999999998224,"possible1":null,"possible2":null,"bedrock_percent":"0","mud_precent":"0","mudbrick_precent":null,"nari_percent":"0","orientation":"14","stone_percent":"0","limestone_percent":"100","other_name":null,"stratigraphy_remarks":null,"upper_height":0.2000000000000000111,"ceramic_quality_1":null,"ceramic_quality_2":null,"earth_percent":"0","remarks":null,"bedrock_quality_1":null,"bedrock_quality_2":null,"plan_type":"Linear","plaster_quality_1":null,"plaster_quality_2":null,"upper_width":0.54000000000000003553},"reason":"Stacked stones along Wall 9","artifacts":[],"state":"approved","designation":"Stone bench along Wall 9","draw_balks":null,"function":"Stone bench along Wall 9 opposite the cultic niche in the LB building","sample_remarks":null,"couchrest-type":"Locus","pails":[],"balk":null,"locus_type":"Installation","samples":[],"bottom_separation":"Clear","stratigraphies":[{"related_locus":"B8K11:033","is_related":"Under","related":"Earth layer"},{"related_locus":"B8K11:009","is_related":"Abuts","related":"Wall"},{"related_locus":"B8K11:035","is_related":"Sealed agnst by","related":"Surface"},{"related_locus":"B8K11:038","is_related":"Over","related":"Surface"}],"sample_reason":null,"start_date":"2006-07-30","stratigraphy_remarks":"Later than Wall 9; earlier than Surf 35","supervisor":"M. Vincent","photos":[{"upload_content_type":"image/jpeg","upload_file_size":2380984,"date":"2006-07-30","subject":"Progress","legacy_number":null,"number":"06B11398","upload_file_name":"06B11398.jpg","upload_updated_at":"2010-08-07T10:27:11Z"},{"upload_content_type":null,"upload_file_size":null,"date":"2006-08-02","subject":"Final Field B","legacy_number":null,"number":"06B11446","upload_file_name":null,"upload_updated_at":null},{"upload_content_type":"image/jpeg","upload_file_size":89717,"date":"2008-06-30","subject":"Progress","legacy_number":null,"number":"08B11030","upload_file_name":"08B11030.jpg","upload_updated_at":"2010-08-07T10:43:16Z"},{"upload_content_type":null,"upload_file_size":null,"date":"2008-07-04","subject":"Progress","legacy_number":null,"number":"08B11123","upload_file_name":null,"upload_updated_at":null},{"upload_content_type":"image/jpeg","upload_file_size":1306176,"date":"2008-07-09","subject":"Progress","legacy_number":null,"number":"08B11203","upload_file_name":"08B11203.jpg","upload_updated_at":"2010-08-07T10:43:19Z"},{"upload_content_type":"image/jpeg","upload_file_size":176731,"date":"2008-07-29","subject":"Final: LB building central shrine","legacy_number":null,"number":"08B11636","upload_file_name":"08B11636.jpg","upload_updated_at":"2010-08-07T10:43:21Z"},{"upload_content_type":"image/jpeg","upload_file_size":230862,"date":"2008-07-29","subject":"Final: LB building","legacy_number":null,"number":"08B11622","upload_file_name":"08B11622.jpg","upload_updated_at":"2010-08-07T10:43:22Z"},{"upload_content_type":"image/jpeg","upload_file_size":239014,"date":"2008-07-29","subject":"Final: LB building NW part","legacy_number":null,"number":"08B11620","upload_file_name":"08B11620.jpg","upload_updated_at":"2010-08-07T10:43:23Z"}],"cron_type":null,"age":"Late Bronze 2","code":"037","created_at":"2010-07-05T16:06:10Z","levels":[{"bottom_is_legacy":true,"burial":0,"method_top":"T","bottom_level":909.21000000000003638,"top_is_legacy":true,"top_level":909.50999999999999091,"method_bottom":null,"location":5},{"bottom_is_legacy":true,"burial":0,"method_top":"T","bottom_level":909.27999999999997272,"top_is_legacy":true,"top_level":909.40999999999996817,"method_bottom":null,"location":11}],"updated_at":"2010-07-31T09:44:26Z"}}
]}

Calling with multiple keys

RESTful Query

GET opendig-development/_design/OpenDigRails/_view/locus?keys=["B8K11:037", "B8K11:038"]

JSON Result

{"total_rows":3918,"offset":1541,"rows":[
{"id":"778d41ddabf2e4b20673f8af54748abd","key":"B8K11:037","value":{"_id":"778d41ddabf2e4b20673f8af54748abd","_rev":"1-884cae78b3d3024577138acdf2b2003a","field":"B","top_separation":"Clear","square":"8K11","architecture":"0","clean_locus":false,"end_date":"2008-07-09","sub_balks":null,"top_plan":"32,33","installation_description":{"other_percent":"0","plan_quality_1_other":null,"plan_quality_2_other":null,"type":"InstallationDescription","certain":null,"earth_quality_1":null,"earth_quality_2":null,"plan_quality_1":"None","plan_quality_2":null,"mud_quality_1":null,"mud_quality_2":null,"lower_height":0.17999999999999999334,"nari_quality_1":null,"nari_quality_2":null,"other_quality_1":null,"other_quality_2":null,"ceramic_percent":"0","length":2.2999999999999998224,"mudbrick_quality_1":null,"mudbrick_quality_2":null,"plan_remarks":null,"plaster_percent":"0","probable1":"Bench","stone_quality_1":null,"stone_quality_2":null,"lime_quality_1":"Hard","lime_quality_2":null,"lining":"None","lower_width":0.47999999999999998224,"possible1":null,"possible2":null,"bedrock_percent":"0","mud_precent":"0","mudbrick_precent":null,"nari_percent":"0","orientation":"14","stone_percent":"0","limestone_percent":"100","other_name":null,"stratigraphy_remarks":null,"upper_height":0.2000000000000000111,"ceramic_quality_1":null,"ceramic_quality_2":null,"earth_percent":"0","remarks":null,"bedrock_quality_1":null,"bedrock_quality_2":null,"plan_type":"Linear","plaster_quality_1":null,"plaster_quality_2":null,"upper_width":0.54000000000000003553},"reason":"Stacked stones along Wall 9","artifacts":[],"state":"approved","designation":"Stone bench along Wall 9","draw_balks":null,"function":"Stone bench along Wall 9 opposite the cultic niche in the LB building","sample_remarks":null,"couchrest-type":"Locus","pails":[],"balk":null,"locus_type":"Installation","samples":[],"bottom_separation":"Clear","stratigraphies":[{"related_locus":"B8K11:033","is_related":"Under","related":"Earth layer"},{"related_locus":"B8K11:009","is_related":"Abuts","related":"Wall"},{"related_locus":"B8K11:035","is_related":"Sealed agnst by","related":"Surface"},{"related_locus":"B8K11:038","is_related":"Over","related":"Surface"}],"sample_reason":null,"start_date":"2006-07-30","stratigraphy_remarks":"Later than Wall 9; earlier than Surf 35","supervisor":"M. Vincent","photos":[{"upload_content_type":"image/jpeg","upload_file_size":2380984,"date":"2006-07-30","subject":"Progress","legacy_number":null,"number":"06B11398","upload_file_name":"06B11398.jpg","upload_updated_at":"2010-08-07T10:27:11Z"},{"upload_content_type":null,"upload_file_size":null,"date":"2006-08-02","subject":"Final Field B","legacy_number":null,"number":"06B11446","upload_file_name":null,"upload_updated_at":null},{"upload_content_type":"image/jpeg","upload_file_size":89717,"date":"2008-06-30","subject":"Progress","legacy_number":null,"number":"08B11030","upload_file_name":"08B11030.jpg","upload_updated_at":"2010-08-07T10:43:16Z"},{"upload_content_type":null,"upload_file_size":null,"date":"2008-07-04","subject":"Progress","legacy_number":null,"number":"08B11123","upload_file_name":null,"upload_updated_at":null},{"upload_content_type":"image/jpeg","upload_file_size":1306176,"date":"2008-07-09","subject":"Progress","legacy_number":null,"number":"08B11203","upload_file_name":"08B11203.jpg","upload_updated_at":"2010-08-07T10:43:19Z"},{"upload_content_type":"image/jpeg","upload_file_size":176731,"date":"2008-07-29","subject":"Final: LB building central shrine","legacy_number":null,"number":"08B11636","upload_file_name":"08B11636.jpg","upload_updated_at":"2010-08-07T10:43:21Z"},{"upload_content_type":"image/jpeg","upload_file_size":230862,"date":"2008-07-29","subject":"Final: LB building","legacy_number":null,"number":"08B11622","upload_file_name":"08B11622.jpg","upload_updated_at":"2010-08-07T10:43:22Z"},{"upload_content_type":"image/jpeg","upload_file_size":239014,"date":"2008-07-29","subject":"Final: LB building NW part","legacy_number":null,"number":"08B11620","upload_file_name":"08B11620.jpg","upload_updated_at":"2010-08-07T10:43:23Z"}],"cron_type":null,"age":"Late Bronze 2","code":"037","created_at":"2010-07-05T16:06:10Z","levels":[{"bottom_is_legacy":true,"burial":0,"method_top":"T","bottom_level":909.21000000000003638,"top_is_legacy":true,"top_level":909.50999999999999091,"method_bottom":null,"location":5},{"bottom_is_legacy":true,"burial":0,"method_top":"T","bottom_level":909.27999999999997272,"top_is_legacy":true,"top_level":909.40999999999996817,"method_bottom":null,"location":11}],"updated_at":"2010-07-31T09:44:26Z"}},
{"id":"778d41ddabf2e4b20673f8af5493e677","key":"B8K11:038","value":{"_id":"778d41ddabf2e4b20673f8af5493e677","_rev":"1-defd55bee0fb41e3319386c0ed993606","field":"B","top_separation":null,"square":"8K11","architecture":"0","clean_locus":false,"end_date":"2008-07-09","sub_balks":null,"top_plan":null,"reason":"Hard plaster","earth_description":{"carbonized_other_number":0,"earth_other_frequency":0,"burnt_wood_count":0,"pottery":null,"type":"EarthDescription","boulders":0,"shape_a":25,"slope":"2","wetness_description":"Dry","structure":"Random","compactness_degree_2":null,"olive":0,"tabun_fragments":0,"roof_tiles":0,"organic_pocket_size":0,"munsel":"10YR 7/1","pebble_size":0,"wetness_degree":"moderately","length":5,"surface_material":"Plaster","burned_stone":null,"compactness_description_1":"Firm","ash_size":0,"organic_other_size":0,"worked_stone":0,"remarks":"Also 2.5Y 8/1, white","architectural_fragments_description":null,"locus_type":"E","shape_sr":25,"stratigraphy_remarks":null,"earth_other_name":null,"architectural_fragments_count":null,"texture":"Sand clay loam-Silty clay loam","organic_distribution":null,"compactness_degree_1":"very","pebble_frequency":0,"nari_size":0,"glass":0,"unidentifiable_number":0,"stone_distribution":"Random","brick_frequency":0,"nari_frequency":0,"brick_fragments":0,"artifact_distribution":null,"shells":0,"hardness":"Hard","lower_depth":0,"brick_size":0,"carbonized_other_name":null,"cobbles":0,"artifact_other_count":0,"unidentifiable_size":0,"upper_depth":0,"organic_other_name":null,"tesserae":0,"pebbles":300,"burnt_wood_size":0,"width":4,"lam_number":"0","shape_r":25,"carbonized_other_size":0,"flint":null,"organic_other_number":0,"ash_frequency":0,"artifact_other_name":null,"earth_distribution":null,"organic_pocket_number":0,"shape_as":25,"bones":null,"direction":"10","compactness_description_2":null,"earth_other_size":0},"artifacts":[],"state":"approved","designation":"Earliest phase LB floor in the shrine room","draw_balks":null,"function":"Earliest floor of the central shrine room of the LB building","sample_remarks":null,"couchrest-type":"Locus","pails":[],"balk":null,"locus_type":"Earth","samples":[],"bottom_separation":null,"stratigraphies":[{"related_locus":"B8K11:035","is_related":"Under","related":"Surface"},{"related_locus":"B8K11:037","is_related":"Under","related":"Installation"},{"related_locus":"B8K11:039","is_related":"Contiguous to","related":"Surface"},{"related_locus":"B8K11:009","is_related":"Seals against","related":"Wall"},{"related_locus":"B8K11:010","is_related":"Seals against","related":"Wall"},{"related_locus":"B8K11:030","is_related":"Seals against","related":"Wall"},{"related_locus":"B8K11:032","is_related":"Seals against","related":"Installation"}],"sample_reason":null,"start_date":"2008-06-30","stratigraphy_remarks":"Later than the walls of the central shrine room","supervisor":"M. Vincent","photos":[{"upload_content_type":null,"upload_file_size":null,"date":"2008-07-04","subject":"Progress","legacy_number":null,"number":"08B11123","upload_file_name":null,"upload_updated_at":null},{"upload_content_type":"image/jpeg","upload_file_size":1338094,"date":"2008-07-08","subject":"Progress","legacy_number":null,"number":"08B11168","upload_file_name":"08B11168.jpg","upload_updated_at":"2010-08-07T10:43:17Z"},{"upload_content_type":"image/jpeg","upload_file_size":1306176,"date":"2008-07-09","subject":"Progress","legacy_number":null,"number":"08B11203","upload_file_name":"08B11203.jpg","upload_updated_at":"2010-08-07T10:43:19Z"},{"upload_content_type":"image/jpeg","upload_file_size":176731,"date":"2008-07-29","subject":"Final: LB building central shrine","legacy_number":null,"number":"08B11636","upload_file_name":"08B11636.jpg","upload_updated_at":"2010-08-07T10:43:21Z"},{"upload_content_type":"image/jpeg","upload_file_size":230862,"date":"2008-07-29","subject":"Final: LB building","legacy_number":null,"number":"08B11622","upload_file_name":"08B11622.jpg","upload_updated_at":"2010-08-07T10:43:22Z"},{"upload_content_type":"image/jpeg","upload_file_size":239014,"date":"2008-07-29","subject":"Final: LB building NW part","legacy_number":null,"number":"08B11620","upload_file_name":"08B11620.jpg","upload_updated_at":"2010-08-07T10:43:23Z"},{"upload_content_type":"image/jpeg","upload_file_size":183696,"date":"2008-07-29","subject":"Final: LB building NW part 2","legacy_number":null,"number":"08B11628","upload_file_name":"08B11628.jpg","upload_updated_at":"2010-08-07T10:43:24Z"},{"upload_content_type":"image/jpeg","upload_file_size":188514,"date":"2008-07-29","subject":"Final: LB building 2","legacy_number":null,"number":"08B11629","upload_file_name":"08B11629.jpg","upload_updated_at":"2010-08-07T10:43:25Z"},{"upload_content_type":"image/jpeg","upload_file_size":963111,"date":"2008-07-02","subject":"Progress","legacy_number":null,"number":"08B11077","upload_file_name":"08B11077.jpg","upload_updated_at":"2010-08-07T10:43:27Z"},{"upload_content_type":"image/jpeg","upload_file_size":888454,"date":"2008-07-03","subject":"Progress","legacy_number":null,"number":"08B11098","upload_file_name":"08B11098.jpg","upload_updated_at":"2010-08-07T10:43:28Z"}],"cron_type":null,"age":"Late Bronze 2","code":"038","created_at":"2010-07-05T16:06:10Z","levels":[{"bottom_is_legacy":true,"burial":0,"method_top":"T","bottom_level":0,"top_is_legacy":true,"top_level":909.11000000000001364,"method_bottom":null,"location":2},{"bottom_is_legacy":true,"burial":0,"method_top":"T","bottom_level":0,"top_is_legacy":true,"top_level":909.10000000000002274,"method_bottom":null,"location":3},{"bottom_is_legacy":true,"burial":0,"method_top":"T","bottom_level":0,"top_is_legacy":true,"top_level":909.13999999999998636,"method_bottom":null,"location":5},{"bottom_is_legacy":true,"burial":0,"method_top":"T","bottom_level":0,"top_is_legacy":true,"top_level":909.23000000000001819,"method_bottom":null,"location":8},{"bottom_is_legacy":true,"burial":0,"method_top":"T","bottom_level":0,"top_is_legacy":true,"top_level":909.24000000000000909,"method_bottom":null,"location":10},{"bottom_is_legacy":true,"burial":0,"method_top":"T","bottom_level":0,"top_is_legacy":true,"top_level":909.30999999999994543,"method_bottom":null,"location":21},{"bottom_is_legacy":true,"burial":0,"method_top":"T","bottom_level":0,"top_is_legacy":true,"top_level":909.30999999999994543,"method_bottom":null,"location":31},{"bottom_is_legacy":true,"burial":0,"method_top":"T","bottom_level":0,"top_is_legacy":true,"top_level":909.37000000000000455,"method_bottom":null,"location":34}],"updated_at":"2010-07-31T09:44:26Z"}}
]}

Now, what makes CouchDB particularly awesome...

You can embed entire apps within CouchDB.

This reveal.js presentation, is in fact, a CouchApp.

Let's make this thing go live

So, recapping...

CouchDB made OpenDig possible Handles all replicationand synnchronizaiton for me Map/Reduce was frustrating to learn and still feels somewhat clunky compared with MongoDB's quary language BUT... the Map/Reduce + CouchDB's internal authentication system makes it possible to build an entire API within the database itself CouchApps are really powerful, allowing you to make your app and database a single self-contained unit.

Oh, one more thing...

The philosophy (read: my phiolosophy) emphasizes that documents be self contained. Some of the Couch adapters that let you work with ActiveModel (Rails) like objects create different documents when really they should be self contained.

JSON Document

{
  "_id": "my-house",
  "_rev": "blahblahblah",
  "pets": [
    {"type": "cat", "name": "Fluffy"},
    {"type": "cat", "name": "Whiskers"}
  ]
}

Pros

  • fast
  • really easy to duplicate your database
  • flexible data schema (or lack thereof)
  • the power of CouchApps
  • integrated versioning

Cons

  • views can be slow to generate
  • really easy to duplicate your database
  • lack of schema
  • Map/Reduce can be confusing
  • version history is only local

About CouchDB

http://guide.couchdb.org/

#couchdb (Freenode)

Books

GEO, CouchDB & Node.js, Mick Thompson

MapReduce Views in CouchDB, Bradley Holt

Me

matt@averails.com

http://opendig.org

github: github.com/neshmi/fullstack_couchdb

couchdb: opendig.cloudant.com/fullstack_couchdb

slides: fullstack.opendig.org