Skip to content

Instantly share code, notes, and snippets.

@sra

sra/notwork.js Secret

Created September 4, 2012 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sra/112f1eda11939d16d197 to your computer and use it in GitHub Desktop.
Save sra/112f1eda11939d16d197 to your computer and use it in GitHub Desktop.
'membercounts': function() {
console.log("enter mc");
var housecounts = {};
console.log(Houses.find().count());
Houses.find().forEach(function(house){
housecounts[house.name] = {count: Avatars.find({house:house.name, canvote:false, active:true}).count()};
console.log("in loop");
console.log(housecounts);
});
console.log("returning");
console.log(housecounts);
return housecounts;
}
enter mc
4
returning
{}
in loop
{ Wolf: { count: 39 } }
in loop
{ Wolf: { count: 39 }, Lion: { count: 41 } }
in loop
{ Wolf: { count: 39 },
Lion: { count: 41 },
Falcon: { count: 38 } }
in loop
{ Wolf: { count: 39 },
Lion: { count: 41 },
Falcon: { count: 38 },
Dragon: { count: 40 } }
Meteor.methods({
'setGroupAssigned': function(id, newvalue) {
Avatars.update({_id:id}, {$set: {slgroupassigned: newvalue}});
},
'membercounts': function() {
var housecounts = {};
Houses.find().fetch().forEach(function(house){
housecounts[house.name] = {count: Avatars.find({house:house.name, canvote:false, active:true}).count()};
});
return housecounts;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment