As I mentioned in the Post Scriptum of an earlier post, JavaScript is not the only language that you can create CouchDB views with. You can now use PHP, too.
Here is how views work again: You specify a JavaScript function that receives a document parameter (which is a JSON object). You can do whatever to that object and return it again. Or you don’t return anything. When a new document is added to a CouchDB database, it gets passed to the JavaScript function and, depending on its return value, is included into the view that is associated with the function &endash; or not.
function(doc)
{
if("Value" == doc.field) {
return doc;
}
}
This function adds the full document to the view when it has a
field called field and when that has the value
Value. This is just a refresher on how views work …