mongodb 重复执行问题
发布于 9-2 14:52
104 次浏览
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); 会打印两次,怎么回事