couchdb – Euclides http://ezisetup.com/designs/euclides Just another EziSite Mon, 24 Feb 2014 22:11:34 +0000 en-US hourly 1 Joins in Couchdb http://ezisetup.com/designs/euclides/joins-in-couchdb/ http://ezisetup.com/designs/euclides/joins-in-couchdb/#comments Fri, 21 Jan 2011 12:45:27 +0000 http://www.cssigniter.com/preview/euclides/?p=28 Nunc eu ullamcorper orci. Quisque eget odio ac lectus vestibulum faucibus eget in metus. In pellentesque faucibus vestibulum. Nulla at nulla justo, eget luctus tortor. Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur vulputate, ligula lacinia scelerisque tempor, lacus lacus ornare ante, ac egestas est urna sit amet arcu. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed molestie augue sit amet leo consequat posuere.

[javascript]
MAP
function(doc) {
if(doc.doc_type == “User”){
emit(doc._id , doc);
}
else if(doc.doc_type == “Message”){
emit(doc.owner, doc)
}
}

REDUCE
function(keys, values)
{
var result = {“messages”:[]};
for(var i=0; i<values.length; i++){
if(values[i].doc_type == “User”){
for(v in values[i]){
result[v] = values[i][v];
}
}
else if(values[i].doc_type == “Message”){
result[‘messages’].push( values[i] );
}
}

return result;
}
[/javascript]

]]>
http://ezisetup.com/designs/euclides/joins-in-couchdb/feed/ 3