Dushyant Bangal Dushyant Bangal - 2 years ago 303
Node.js Question

mongoose db.stats() equivalent

I'm using mongoose, and I need to get stats of database.

I know about

, but thats just for a collection, I need similar thing, but for the database.

Please dont suggest running the shell command. I want to do it using mongoose.

Answer Source

You can call db.stats on the mongoose.connection object:

var mongoose = require('mongoose');

var db = mongoose.connection;

db.on('error', console.error.bind(console, 'connection error:'));

db.once('open', function() {
  db.db.stats(function(err, stats) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download