2014-10-08 43 views
0
/* set up get all the tools we need */ 

var express = require('express'), 
moment = require('moment'), 
app  = express(), 
bodyParser = require('body-parser'), 
port  = process.env.PORT || 21017, 
mongoose = require('mongoose'); 



// configuration connect to our database mongodb://localhost/HelloMongoose*/ 

var configDB = require('./config/database.js'); 

mongoose.connect(configDB.url, function(err,res){ 

    if(err){ 
     console.log('Error connecting to:' + configDB.url + '. '+ err); 
    }else{ 
     console.log('Succeeded connecting to:' + configDB.url); 
} 
}); 


app.engine('html', require('ejs').renderFile); 

app.use(bodyParser.urlencoded({ 

extended:false 

})); 

app.use(require('express-promise')()); //setup inline promises 

app.use(express.static(process.cwd() + '/public')); 




//models 

var reminderSchema = mongoose.Schema({ 

title: String, 
isCompleted: Boolean, 
end: { type: Date, default: moment().add(1, 'd').toDate() } 
}); 

var Reminder = mongoose.model('Reminder', reminderSchema); 

// launch 

app.listen(port); 

console.log('The magic happens on port ' + port); 

當我運行Ubuntu的,從$ 14節點服務器日誌顯示此:瀏覽器responsed到server.js

 
The magic happens on port 21017 
Succeeded connecting to:mongodb://localhost/HelloMongoose 

但是當我瀏覽到MongoDB的鏈接://本地主機:21027/HelloMongoose我得到

 
the address wasn't understood" by mozilla firefox. 

回答

0

嘗試連接這樣的:

mongodb://127.0.0.1/HelloMongoose 
+0

它迪不工作,我得到了一個搜索結果。 – 2014-10-10 21:03:15

+0

我強烈建議獲取RoboMongo。這是檢查你的mongodb數據庫的好軟件,它是開源的,它是免費的! http://robomongo.org/ – codephobia 2014-10-11 06:10:04