LoginSignup
0
4

More than 5 years have passed since last update.

mongodbでコレクションごとのレコード数を表示

Posted at

mongodbでコレクションの一覧を取得し、コレクションのレコード数を表示させるクエリは以下になります。

db.getCollectionNames().forEach(function(n){print(n + ':' + db[n].find().count())})

上記の応用で、コレクションごとのストレージサイズを表示させるには以下になります。

db.getCollectionNames().forEach(function(n){print(n + ':' + db[n].stats().storageSize)})
0
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
4