xl0shk
xl0shk

Reputation: 61

How to count the number of databases in mongod by mongo shell?

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

Answers (1)

Jonathan Muller
Jonathan Muller

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

Related Questions