当使用MongoClientv3.0时,db.Collection不是函数
TypeError: db.collection is not a function at c:\Users\user\Desktop\Web Project\WebService.JS:79:14 at args.push (c:\Users\user\node_modules\mongodb\lib\utils.js:431:72) at c:\Users\user\node_modules\mongodb\lib\mongo_client.js:254:5 at connectCallback (c:\Users\user\node_modules\mongodb\lib\mongo_client.js:933:5) at c:\Users\user\node_modules\mongodb\lib\mongo_client.js:794:11 at _combinedTickCallback (internal/process/next_tick.js:73:7) at process._tickCallback (internal/process/next_tick.js:104:9)
var MongoClient = require('mongodb').MongoClient;var url = "mongodb://localhost:27017/mytestingdb";MongoClient.connect(url, function(err, db) { if (err) throw err; db.collection("customers").findOne({}, function(err, result) { if (err) throw err; console.log(result.name); db.close(); });});
db.collection("customers").findOne({}, function(err, result) {}
慕姐8265434
斯蒂芬大帝
相关分类