Executing admin commands from Atlas Serverless Function

I’m trying to execute admin commands from Atlas Serverless Functions, I’m unable to figure out how to execute admin commands such as currentOp

The docs explain the use of admin() which returns an instance of AdminDatabase but it’s unclear how to execute commands through this object.

It explains The mongodb.admin() method returns an AdminDatabase object. The object contains helper methods that wrap a subset of MongoDB database commands. See admin.getDBNames()

But doesn’t expand on any additional functions/commands.

I would expect that I’d be able to execute commands like context.service.get('Cluster0').admin().command({currentOp: 1})

Any additional guidance would be much appreciated.

Hi Matt,

Admin commands in functions are generally not supported.

The document you’ve referenced is specifically for the use of admin.getDBNames() which is the exception. Please see article below detailing which commands are supported:



So is admin().getDBNames() the only admin command supported?

Is there a specific reason this?