我从the Mongoose website开始阅读快速入门,几乎复制了代码,但我无法使用Node连接MongoDB.js.
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
exports.test = function(req, res) {
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
console.log("h1");
db.once('open', function callback () {
console.log("h");
});
res.render('test');
};
这是我的密码.控制台只打印h1
,而不是h
.我错在哪里?