以前只是瞭解Nodejs 這回打算好好學學。學到熟練使用的程度
var options={ user:'test_user', pass:'123456' }; mongoose.connect('mongodb://127.0.0.1/test',options); var User = mongoose.model('User', { name: String ,des:String}); app.get("/",function(req,res){ User.find({},function(err,users){ console.info(err); res.render("user",{users:users}) }); }); var initCount=0; app.get("/add",function(req,res){ var user = new User({name:'user'+(initCount++)}); user.save(); res.redirect("/"); });