In MongoDB shell you can use db.runCommand(...). For example to show mongoDB users :
> db.runCommand({usersInfo:1})
....
list of users
....
This would be useful for User management commands
What is the equivalent in mongoose ?
In MongoDB shell you can use db.runCommand(...). For example to show mongoDB users :
> db.runCommand({usersInfo:1})
....
list of users
....
This would be useful for User management commands
What is the equivalent in mongoose ?
I've found out here that we can use db.db.command :
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/test', {useNewUrlParser: true, useUnifiedTopology: true});
var db = mongoose.connection;
db.once('open', function callback () {
db.db.command({usersInfo: 1}, function (err,result){
console.log(result);
mongoose.disconnect();
});
});