I have created chat application using node.js , socket.io and mongodb on Cloud9.
I have created schema and model using this code :
//mongoose connect
mongoose.connect('mongodb://test-mmnnww123.c9users.io:27017/chat', function(err){
if(err){
console.log(err);
}else{
console.log('CONNECTED!');
}
});
//mongoose model
var chatSchema = mongoose.Schema({
nick : String,
msg : String,
created : {type : Date, default: Date.now}
});
var Chat = mongoose.model('Message', chatSchema);
Everything works perfectly and I store the data successfully but I couldn't view the data, in other words i want to show that table that I have created which is called Message.
Is there URL for it or any npm command should I write to view it?
I'm not sure if you can connect to the mongodb server like that. Since cloud9 only exports ports 8080
, 8081
, and 8082
you won't be able to access 27017
externally.
To access the local mongodb server, you should be able to use mongodb://localhost:27017
instead and that should work.