initial commit
This commit is contained in:
7
views/all/map.js
Normal file
7
views/all/map.js
Normal 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
12
views/headers/map.js
Normal 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
22
views/headers/reduce.js
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user