猫鼬中的runCommand等效于什么? [英] What is the equivalent of runCommand in mongoose?
本文介绍了猫鼬中的runCommand等效于什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在MongoDB Shell中,您可以使用 db.runCommand(...)
.例如显示mongoDB用户:
In MongoDB shell you can use db.runCommand(...)
. For example to show mongoDB users :
> db.runCommand({usersInfo:1})
....
list of users
....
这对于用户管理命令非常有用
猫鼬是什么?
推荐答案
我发现了在这里,我们可以使用db.db.command
:
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();
});
});
这篇关于猫鼬中的runCommand等效于什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文