
Untitled
By: a guest on Jan 28th, 2012 | syntax:
None | size: 0.64 KB | hits: 35 | expires: Never
function(doc) {
if (doc.type == 'user') {
emit(doc._id, doc.username);
} else if (doc.type == 'picture' && doc.published_datetime > 1) {
delete doc.exif;
emit(doc.user_id, doc);
}
}
function(key, values) {
var dump = [], pics = [];
for (var x = 0, y = values.length; x < y; x++) {
var doc = values[x];
if (doc.type == 'user') {
dump.push(doc);
} else if (doc.type == 'picture') {
pics.push(doc);
}
}
pics.sort(function(a, b) {
return a.published_datetime < b.published_datetime;
});
for (var x = 0; x < 10; x++) {
var doc = pics.shift();
if (doc) {
dump.push(doc);
}
}
return dump;
}