Where developers come to connect, share, build and be inspired.

10

Javascript: The language of CouchDB

813 views

CouchDB replaces SQL Queries with JavaScript MapReduce AKA. views. A view returns a range of objects in the database, and the developer has to decide either to do the calculations on the db or on the client.

The following example will display documents with the _id of "tester". Notice the optional server-side logic in this request

function(doc) {
  theData = "Revision: "+doc._rev+" Key: "+doc._id;
  theKey = "Custom Key "+doc._id;
  if(doc._id == "tester"){ emit(theKey, theData); }
}

endorse

Comments

Add a comment