📜  节点 mongodb 选择集合 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:12.709000             🧑  作者: Mango

代码示例1
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  var dbo = db.db("mydb");
  dbo.collection("customers").findOne({}, function(err, result) {
    if (err) throw err;
    console.log(result.name);
    db.close();
  });
});