[英]Node.js Express | JQuery Nothing happens on client when getting a JSON
[英]Node.js Mongoose nothing happens
我正在嘗試連接到我的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
謝謝大家,問題是連接字符串:我不得不使用選項,而不是使用mongodb:// user:pass @ host / db進行連接。 此處有更多詳細信息: http : //mongoosejs.com/docs/connections.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.