initial commit

This commit is contained in:
maxogden
2011-03-08 19:48:57 -08:00
commit 5e2a36bda5
16 changed files with 818 additions and 0 deletions

7
views/all/map.js Normal file
View File

@@ -0,0 +1,7 @@
/**
* A simple map function mocking _all, but allows usage with lists etc.
*
*/
function(doc) {
emit(doc.id, doc);
}

12
views/headers/map.js Normal file
View File

@@ -0,0 +1,12 @@
/**
* Returns an array of all of the keys in the document.
*
* @author Max Ogden
*/
function(doc) {
var keys = [];
for (var key in doc) {
keys.push(key);
}
emit(doc, keys);
}

22
views/headers/reduce.js Normal file
View File

@@ -0,0 +1,22 @@
/**
* Reduces the passed in view headers to a list of unique object key attributes
*
* @author Max Ogden
*/
function(keys, values, rereduce) {
function include(arr, obj) {
return (arr.indexOf(obj) != -1);
}
var headers = [];
for (var doc in values) {
for (var header in values[doc]) {
if(!include(headers, values[doc][header])) {
headers.push(values[doc][header]);
}
}
}
return headers;
}