Skip to content

Instantly share code, notes, and snippets.

@alanhoff
Last active December 16, 2015 02:59
Show Gist options
  • Save alanhoff/5366411 to your computer and use it in GitHub Desktop.
Save alanhoff/5366411 to your computer and use it in GitHub Desktop.
var async = require('async');
var collections = {};
collections.model1 = require('../model/model1');
collections.model2 = require('../model/model2');
// .. infinitamente quantos desejar
var filtro = function(collection, callback){
collections[collection].count().exec(function(err, count){
if(err)
return callback(err);
var result = {}
result[collection] = count;
callback(null, result);
});
};
async.filter(Object.keys(collections), filtro, function(err, counts){
if(err)
throw err;
else
res.render('painel/info', {
title: 'Informações',
subtitle: 'Geral',
menuativo: 'info',
numeros: counts
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment