Commit 7de8fc28 authored by Kim, Subin's avatar Kim, Subin
Browse files

교수님 여기요! 11.06.04:00

parent 3ed89fa4
...@@ -10,7 +10,7 @@ router.post('/', function (req, res, next) { ...@@ -10,7 +10,7 @@ router.post('/', function (req, res, next) {
console.log("writes req.body", req.body) console.log("writes req.body", req.body)
const notice = new Notice({ const notice = new Notice({
notice_title: req.body.title, notice_title: req.body.title,
notice_author: "예진", notice_author: req.body.name,
notice_content: req.body.content notice_content: req.body.content
}); });
console.log(notice); console.log(notice);
...@@ -26,11 +26,13 @@ router.post('/', function (req, res, next) { ...@@ -26,11 +26,13 @@ router.post('/', function (req, res, next) {
}); });
router.put('/:id', function (req, res, next) { router.put('/:id', function (req, res, next) {
console.log('/writes put req.body', req.params) console.log('/writes put req.params', req.params.id)
Notice.findOne({ _id: req.params.id }, function (err, notice) { Notice.findOne({ _id: req.params.id }, function (err, notice) {
if (err) return res.status(500).json({ error: err }); if (err) return res.status(500).json({ error: err });
notice.notice_title = req.body.title + " (수정)"; if (req.body.title.indexOf("(수정)") === -1) {notice.notice_title = req.body.title + " (수정)"}
notice.post_date = req.body.post_date; else {notice.notice_title = req.body.title}
notice.post_date = new Date();
notice.notice_author = req.body.name;
notice.notice_content = req.body.content; notice.notice_content = req.body.content;
notice.save() notice.save()
.then((result) => { .then((result) => {
......
...@@ -11,7 +11,6 @@ const noticeSchema = new Schema({ ...@@ -11,7 +11,6 @@ const noticeSchema = new Schema({
}, },
notice_author: { notice_author: {
type: String, type: String,
// default: "나야나"
required: true, required: true,
}, },
post_date: { post_date: {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment