This shows you the differences between two versions of the page.
mvp_1.0_couchdb_views [2017/07/05 14:28] webbhm created |
mvp_1.0_couchdb_views [2017/07/05 14:31] (current) webbhm |
||
---|---|---|---|
Line 1: | Line 1: | ||
===== CouchDB Views ===== | ===== CouchDB Views ===== | ||
As always, refer to the [[http://guide.couchdb.org/draft/views.html |manuals]] for the best documentation. | As always, refer to the [[http://guide.couchdb.org/draft/views.html |manuals]] for the best documentation. | ||
- | The easiest way to create views is to click on the mvp_sensor_data database to navigate down into it, then under the menu "View" go to the "temporary view" and create a new one (or edit an existing one). Click on the "View Code" window arrow to drop down the code editing window. The view I created has the following code: | + | The easiest way to create views is within CouchDB Futon (the web interface). Click on the mvp_sensor_data database to navigate down into it, then under the menu "View" go to the "temporary view" and create a new one (or edit an existing one). Click on the "View Code" window arrow to drop down the code editing window. The view I created has the following code: |
- | function(doc) { | + | function(doc) { |
if(doc.value && doc.attribute && doc.status == 'Success') | if(doc.value && doc.attribute && doc.status == 'Success') | ||
{ | { | ||
emit([doc.attribute, doc.name, doc.timestamp], doc); | emit([doc.attribute, doc.name, doc.timestamp], doc); | ||
} | } | ||
- | } | + | } |
The bottom window shows the query results. | The bottom window shows the query results. |