0
router.route('/')
.post((req, res) => {
Circle.findOne({title: req.params.circle_title}, (err, circle) => {
if (err) {
return res.send(err)
}
circle.posts.push({
authorId: req.body.authorId,
body: req.body.body
})
circle.save((err, savedCircle) => {
if (err) {
return res.send(err)
}
res.json(savedCircle.posts[savedCircle.posts.length-1]) // FIXME
})
})
})
在上面的代碼中的子文檔,我想知道是否有更好的方法來返回剛保存的,這是一個circle
的子文檔post
。貓鼬讓剛剛存
爲什麼不返回'_id'新職位和查詢'郵政'收集? – Baruch
如果答案不符合標準/不適用於您,您是否可以更新評論中的原因? –