Dushyant Bangal Dushyant Bangal - 1 year ago 172
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.


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) {