我在nodejs中试过这个,但我在控制台中得到未定义的输出
// Connect using a MongoClient instance
const MongoClient = require("mongodb").MongoClient;
const test = require("assert");
// Connection url
const url = "mongodb://localhost:27017";
// Database Name
const dbName = "test";
// Connect using MongoClient
const mongoClient = new MongoClient(url);
mongoClient.connect(function (err, client) {
const db = client.db(dbName);
try {
db.collection("employeeDetails")
.find({})
.toArray(function (err, res) {
console.log(res);
});
} catch (e) {
console.log(e);
} finally {
client.close();
}
});
我如何在我的控制台中获取我的员工详细信息 任何帮助将不胜感激