????6?????index.js?????????????????????????????????У??????????????????????????????model??????????????????
????var User = require('../models/user');
????/*
????* GET home page.
????*/
????exports.index = function(req?? res){
????User.find({}?? function (err??users) {
????res.render('index'?? { title: 'Express'??users:users });
????});
????};
????exports.reg=function(req??res){
????res.render('reg'??{title:'Register Page'});
????};
????exports.doReg=function(req??res){
????var user = new User(req.body.user);
????user.save(function (err?? user) {
????if(!err) {
????console.log(user);
????res.redirect('/')
????}
????});
????console.log(req.body.user);
????};
??????????????????req.body.user???????????д????????user[]????????????????????????дname="username"???????????????????????????
????var user = new User({
????name:req.body['username']??
????password:req.body['password']
????});
????user.save????????????????????????÷????ο?????????save??????????????????????ɡ????????????????Щ?????????????
????7??????????????δ?????????????????????index.js???????????
????var User = require('../models/user');
????/*
????* GET home page.
????*/
????exports.index = function(req?? res){
????User.find({}?? function (err??users) {
????res.render('index'?? { title: 'Express'??users:users });
????});
????};
????exports.login=function(req??res){
????res.render('log'??{title:'Login Page'});
????} ;
????exports.doLogin=function(req??res){
????var user = req.body.user;
????User.find(user??function(err??docs){
????if(!err){
????if(docs!=''){
????console.log(docs);
????return res.redirect('/');
????} else{
????console.log('??????????????');
????return res.redirect('/log');
????}
????}else{
????console.log("Something happend.");
????}
????})
????};
????exports.reg=function(req??res){
????res.render('reg'??{title:'Register Page'});
????};
????exports.doReg=function(req??res){
????var user = new User(req.body.user);
????user.save(function (err?? user) {
????if(!err) {
????console.log(user);
????res.redirect('/')
????}
????});
????console.log(req.body.user);
????};
???????????find()????????????????÷?????????????????????user??????????????????????????????????????user[]????????????name???????????????????{naem:req.body['username']??password:req.body['password']}??????д???????????docs???????????????????
????????????????