How to run db.currentOp() using the MongoDB native Node.js driver?

mongodb, node.js

Solution

The way to do this directly from node mongodb native driver:

var MongoClient = require('mongodb').MongoClient;

MongoClient.connect('mongodb://127.0.0.1:27017/', function (err, db) {

    if (err) { throw err; }

    db.collection('$cmd.sys.inprog').findOne(function (err, data) {

        if (err) { throw err; }
        console.log(data.inprog);

    });
});

Problem

I can't seem to find a way of retrieving information on the database current operation using the mongodb module in Node.js. I have tried something this: ``` mongodb = require 'mongodb' server = new mongodb.Server 'localhost', 27017 connector = new mongodb.Db 'test', server connector.open (err, db) -> if not err? db.admin().command {currentOp: 1}, (err, doc) -> if not err? console.log doc ``` of course without any result. Does anybody have a pointer?

Original source