publish-counts

Gère des compteurs de collection pour des statistiques par exemple.

https://github.com/percolatestudio/publish-counts

$ meteor add tmeasday:publish-counts

Définition d'une collection:


Players = new Mongo.Collection("players");

Coté Server:


Meteor.publish('stats', function() {
    Counts.publish(this, 'player_total', Players.find());
});

Coté Client:


Meteor.subscribe('stats');


<template name="stats">
    <span>Total players : {{getPublishedCount "player_total"}}</span>
</template>