Reputation: 61
I know how to list all databases in mongod. such as db.getMongo().getDBNames()
show dbs
. But how to count the number of databases?
Upvotes: 2
Views: 3148
Reputation: 7516
You almost got it already
db.getMongo().getDBNames()
returns a JavaScript array, so to get the length of it, just do:
db.getMongo().getDBNames().length
Upvotes: 7