I just wrote a small program in meteor and using MongoHQ running under Heroku. This simple app will create a live count of how many people submit the email. You can find the example here: DearJJAbrams Here is the collection:
Counts = new Meteor.Collection("supporters");
On client side, I run:
Template.CountWrapper.SupporterCount = function () {
return Counts.find().count();
};
Template.BodySupporter.events({
'click .support-click' : function () {
if ($("#supportInputName").val() != "") {
Supporters.insert({name: $("#supportInputName").val()});
$(".signup-form").fadeOut(600, function() {
$(".thank-you-message").fadeIn(600);
});
}
return false;
}
})
The problem is that when the number of users submit their email include, the database seems to do the count query very slow. Is there any better way to handle this? Thank you.