- mongo統計字段個數和有值個數
db.getCollection("collection_name").mapReduce(
function() { for (var key in this) { emit(key, 1); } },
function(key, values) { return Array.sum(values); },
{out: {inline: 1}}
)
db.getCollection("collection_name").mapReduce(
function() { for (var key in this) { emit(key, 1); } },
function(key, values) { return Array.sum(values); },
{out: {inline: 1}}
)