Last active
December 16, 2015 02:59
-
-
Save alanhoff/5366411 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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