我的后台录入页,录入不到信息,也没检查到代码哪里错了
app.post('/admin/movie/new', function(req, res) {
var id = req.body.movie._id
var movieObj = req.body.movie
var _movie
if(id !== 'undefined') { //对其更新
Movie.findById(id, function(err, movie) {
if (err) {
console.log(err)
}
_movie = _.extend(movie, movieObj) //underscore
_movie.save(function(err, movie) {
if (err) {
console.log(err)
}
res.redirect('/movie/' + movie._id) //重定向
})
})
}
else {
_movie = new Movie({
doctor: movieObj.doctor,
title: movieObj.title,
country: movieObj.country,
language: movieObj.language,
year: movieObj.year,
poster: movieObj.poster,
summary: movieObj.summary,
flash: movieObj.flash
})
_movie.save(function(err, movie) {
if (err) {
console.log(err)
}
res.redirect('/movie/' + movie._id)
})
}
})