我正在尝试连接到我的 mongodb 数据库,但它不起作用:它不运行回调,也没有抛出错误:
var config = require('./config');
var mongoose = require('mongoose');
var schemas = require('./app/schemas');
var model = require('./app/model');
mongoose.connect(config.db_connection, function (err) {
if (err) {
throw err;
}
});
var ModModel = mongoose.model('mods', schemas.modScheme);
var query = ModModel.find();
query.exec('find', function (err, mods) {
if (err) {
throw err;
}
console.log('Retriveing mods...');
console.log(mods);
});
编辑:这个新代码不起作用
这是整个代码:https ://github.com/CraftYourModCorporation/RedstoneHub (可能不完整,路由getmods)
有人可以链接一个使用猫鼬的项目吗?
和输出:
Important: use 'process.env.PORT' as the port and 'process.env.IP' as the host in your scripts!
debugger listening on port 15400
Process terminated