[英]What is the equivalent of runCommand in mongoose?
In MongoDB shell you can usedb.runCommand(...)
.在 MongoDB shell 中,您可以使用db.runCommand(...)
。 For example to show mongoDB users :例如显示 mongoDB 用户:
> db.runCommand({usersInfo:1})
....
list of users
....
This would be useful for User management commands这对用户管理命令很有用
I've found out here that we can use db.db.command
:我在这里发现我们可以使用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();
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.