Skip to content

Instantly share code, notes, and snippets.

@wumingyu12
Created April 25, 2016 08:52
Show Gist options
  • Select an option

  • Save wumingyu12/93819c505a169bb395c82e6dc6d4af85 to your computer and use it in GitHub Desktop.

Select an option

Save wumingyu12/93819c505a169bb395c82e6dc6d4af85 to your computer and use it in GitHub Desktop.
node
/*
1.npm install mongodb -save
2.确保mongodb服务启动
3.ndoe “这个文件名”
*/
var MongoClient = require('mongodb').MongoClient;
var assert = require('assert');
var url = 'mongodb://localhost:27017/test';
MongoClient.connect(url, function(err, db) {
assert.equal(null, err);
console.log("Connected correctly to server.");
db.close();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment