In the shell, all you need to do is the following:
db.getCollectionNames().map(function(name) { return { "name": name, "count": db[name].count() } })
There is no “command”, and there is no “singular” collection request (this is technically still a few requests made for each collection, and a “source” request) to do this, since this is not how MongoDB stores the data. But there is a simple software method, and it is mostly available for all drivers.
source share