打开后立即关闭mongo / mongolian连接?

时间:2012-11-27 01:18:02

标签: node.js mongodb

打开后无法立即关闭连接尝试db.server.close()和server.close()

var Mongolian = require("mongolian");
var server = new Mongolian;
var db = server.db("database");
var shops = db.collection("collection");
db.server.close();
server.close();

1 个答案:

答案 0 :(得分:0)

var Mongolian = require("mongolian");
var server = new Mongolian();
var database = server.db("database")
var db = {
    collection: database.collection("collection"),
};

db.collection.find({},{"id":1}).limit(1).toArray(function(err, array){
    console.log(array);
    server.close();
});

在您提出请求之前,您无法关闭mongo,然后server.close()将起作用。