node.js 学习笔记五:连接mongodb

var mongodb =require('mongodb');
var server = new mongodb.Server('localhost', 27018, {auto_reconnect:true});
var db = new mongodb.Db('mydb', server, {safe:true});
db.open(function(err, db){
    if(!err){
        console.log('connect');
    }else{
        console.log(err);
    }
});

 

posted @ 2013-05-16 11:19  践道者  阅读(4449)  评论(1编辑  收藏  举报