https://www.npmjs.com/package/mongodb
The official MongoDB driver for Node.js. Provides a high-level API on top of mongodb-core that is meant for end users.
照着上面网址的例子做就可以了,然后node app.js
会出现Connected correctly to server 就说明连接成功
app.js内容是网站上说的这个:
var MongoClient=require('mongodb').MongoClient
,assert=require('assert');
//Connection URL
varurl='mongodb://localhost:27017/myproject';
//Use connect method to connect to the Server
MongoClient.connect(url,function(err,db){
assert.equal(null,err);
console.log("Connected correctly to server");
db.close();
});
网友评论