Skip to content

Instantly share code, notes, and snippets.

@cloudhead
Created February 13, 2011 01:41
Show Gist options
  • Save cloudhead/824328 to your computer and use it in GitHub Desktop.
Save cloudhead/824328 to your computer and use it in GitHub Desktop.
// View function to get all users which have a specific room_id
// in their 'rooms' array.
function(doc) {
if (doc.username) {
for (var i = 0; i < doc.rooms.length; i++) {
emit(doc.rooms[i], { avatar_url: doc.avatar_url, username: doc.username });
}
}
}
// Query with "GET /database/_design/users/_view/by_room?key=room_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment