Create admin dashboard in expressjs, the best way to count users without much?

So, I am creating an admin panel for my application. On the admin homepage, I want to show some usage statistics.

Examples: registration within 24 hours, 7 days, 30 days, all the time registration method: user / pass, facebook, twitter, etc.

Now in my router, admin.indexI make asynchronous calls to my db (mongodb using mongoose) to get all the counts in the last callback function, displaying the page.

exports.index = function(req, res){
    async.parallel({ 
            // https://github.com/caolan/async#parallel
            // counts number of users in date ranges
            all_time: function(next) {
                console.log('querying');
                User.count({}, function (err, count) {
                    if (err) return next(err);
                    next(null, count);
                });
            },
            past_day: function(next) {
                console.log('querying');
                User.count({'created_at': {$gte: yesterday}}, function(err, count) {
                    if (err) return next(err);
                    next(null, count);
                });
            },
            week: function(next) {
                console.log('querying');
                User.count({'created_at': {$gte: week}}, function(err, count) {
                    if (err) return next(err);
                    next(null, count);
                });
            },
            month: function(next) {
                console.log('querying');
                User.count({'created_at': {$gte: month}}, function(err, count) {
                    if (err) return next(err);
                    next(null, count);
                });
            },
            // Counts number of user signups for each strategy
            local: function(next) {
                console.log('querying');
                User.count({'strategy': 'local'}, function(err, count) {
                    if (err) return next(err);
                    next(null, count);
                });
            },
            google: function(next) {
                console.log('querying');
                User.count({'strategy': 'google'}, function(err, count) {
                    if (err) return next(err);
                    next(null, count);
                });
            },
            facebook: function(next) {
                console.log('querying');
                User.count({'strategy': 'facebook'}, function(err, count) {
                    if (err) return next(err);
                    next(null, count);
                });
            },
            twitter: function(next) {
                console.log('querying');
                User.count({'strategy': 'twitter'}, function(err, count) {
                    if (err) return next(err);
                    next(null, count);
                });
            }
        }, 
        function(err, r) {
            if (err) throw err;
            res.render('admin/index', {
                appName: Constants.APP_NAME, 
                title: 'Admin',
                total_users: r.all_time,
                yesterday: r.past_day,
                week: r.week,
                month: r.month,
                local: r.local,
                google: r.google,
                facebook: r.facebook,
                twitter: r.twitter
            })
        }
    );
}

, (8 ) . ? CRUD-, . express node, , .

memcached, ? async?

+2
1

-, , , $ operator. , , . , , , .

, . . , 1 10 000 , , , ; .

, , , .

+1

All Articles