mongodb 重复执行问题
var MongoClient = require(’./node_modules/mongodb’).MongoClient
var http = require(‘http’); var db = null;
MongoClient.connect(‘mongodb://127.0.0.1:27017/lbs’, function(err, database) {
if(err) throw err;
db = database;
server.listen(1234);
})
var server =http.createServer(function(req,res){ //console.log(db); db.eval(‘locate(118,24)’,function(err,xx){ console.log(“123”+xx); //res.write(xx); res.end(xx);
});
});
console.log("123"+xx); 会打印两次,怎么回事