Skip to content

Instantly share code, notes, and snippets.

@orestis
Created February 22, 2010 17:26
Show Gist options
  • Save orestis/311274 to your computer and use it in GitHub Desktop.
Save orestis/311274 to your computer and use it in GitHub Desktop.
trying to get a list of stations with their activities
/*
here's an activity document:
{
"name": "a name",
"stations": ["station1", "station2"]
}
I want a view that will return something like this:
[
{"station1": ["activity_1", "activity_2"]},
{"station2": ["activity_2", "activity_3"]}
]
*/
/*
update: This was simpler than I imagined.
?key="alcove4"
gives this:
{"total_rows":14,"offset":0,"rows":[
{"id":"7f7cbcc33fad2dd105c7295966b478ae","key":"alcove4","value":"7f7cbcc33fad2dd105c7295966b478ae"},
{"id":"8565e47c094f7642c37e36656daeef28","key":"alcove4","value":"8565e47c094f7642c37e36656daeef28"}
]}
*/
map = function(doc) {
if (doc.type == 'Activity') {
doc.stations.forEach(function(st) {
emit(st, doc._id)
});
};
}
reduce = null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment