5 Things You Didn't Know You Could do with CouchDB

8
Five Things You Didn't Know You Could do with CouchDB Mark J. Headd Voxeo Labs @mheadd

description

A discussion of 5 cool features in CouchDB that you might not know about.

Transcript of 5 Things You Didn't Know You Could do with CouchDB

Page 1: 5 Things You Didn't Know You Could do with CouchDB

Five Things You Didn't Know You Could do with CouchDB

Mark J. HeaddVoxeo Labs@mheadd

Page 2: 5 Things You Didn't Know You Could do with CouchDB

CouchDB in Review

• Document-oriented database (NoSQL).• "Schemaless."• Documents stored as JSON.• Queries ("views") structured as JavaScript Map/Reduce.• RESTful API  - actually, more than 1:

o Bulk Document APIo Database APIo Document APIo Changes API

Page 3: 5 Things You Didn't Know You Could do with CouchDB

Geographic Queries

• Ability to query CouchDB based on location.• GeoCouch - formerly a separate fork of CouchDB proper.• GeoCouch baked in to CouchDB 1.0.2.• DBs with a "spatial" key in design doc - spatial indexing.• Special HTTP query to spatial view in design document.• Returns locations within specified bounding box.• Example.

Page 4: 5 Things You Didn't Know You Could do with CouchDB

Change Notifications

• _changes endpoint provides information on all changes.• Simple HTTP GET will list changes.• JSON payload delivered when change(s) occurs.• Long running HTTP connections.• Listening for specific changes with filters.• Example. 

Page 5: 5 Things You Didn't Know You Could do with CouchDB

Formatting with List and Show

• Special types of design document elements - list and show.• Purpose is to render CouchDB docs in other formats.• Show functions operate on a specified document.• List functions operate on the output of view queries.• Both are "side effect free" - no additional operations.• Examples.

Page 6: 5 Things You Didn't Know You Could do with CouchDB

URL Rewriting

• URL paths to display output can be unfriendly.• CouchDB includes powerful rewrite features.• Special design document entry called "rewrites".• Special configuration setting "vhosts".• Ability to use short (friendly) URLs with CouchDB endpoints.• Can condition on HTTP method used, access params.• Example.

Page 7: 5 Things You Didn't Know You Could do with CouchDB

CouchApps

• Framework for serving HTML/JavaScript apps from Couch.• Leverages the formatting, rewrite features discussed.• Can leverage the same jQuery logic used by Futon.• Easy to deploy / replicate.• Remote Agent example.

Page 8: 5 Things You Didn't Know You Could do with CouchDB

Questions?