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
如果答案不符合标准/不适用于您,您是否可以更新评论中的原因? –