更新时间:2023-02-14 12:42:39
虽然这个问题是 5 年前提出的,但现在我想回答一下.所以我正在使用版本为 3.5.6 的 mongodb 本机驱动程序,这是我的解决方案.
Although this question is asked 5 years ago, I'd like to answer it now. So I'm using mongodb native driver of version: 3.5.6 and here's my solution.
let mongoClient = new MongoClient(url, { useNewUrlParser: true, useUnifiedTopology: true });
mongoClient.connect(function(err, client){
assert.equal(null, err);
client.db('dbName').command({usersInfo:1 }).then((userList)=>{
console.log('user List',util.inspect(userList, {showHidden: false, depth: null}));
})
.catch((err)=>{
console.log(err);
});
}
希望这会有所帮助!