使用asp.net更新MongoDB中的子文档 [英] Update sub document in MongoDB using asp.net with example

查看:95
本文介绍了使用asp.net更新MongoDB中的子文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我正在使用ASP.NET中的MongoDB,刚刚阅读了一篇文章,其中有一篇博客文章示例,并提到了以下步骤来更新评论(子文档)。

博客被拍成了主要文件

评论被视为子文档并与主文档一起发布

当我们需要向特定博客插入新评论时,我们是获取现有博客文档,在前端添加新评论(子文档)并再次使用博客ID更新博客文档。

如果是这样的话,让我们采取非常受欢迎的博客场景评论被发布到博客上。如果必须发布任何新评论,我们需要从DB服务器获取所有现有评论到Web服务器,因此它会增加网络流量。

这是一般情况还是有其他替代方式向子文档添加新内容?意思是,我需要一个功能,只需在现有文档中插入新值。

Right now I am working on MongoDB in ASP.NET and just gone through an article in which it has taken a blog post example and mentioned the following steps to update comments (sub document).
The blog was taken a main document
Comments were taken as sub document and posted along with main document
When we need to insert a new comment to a particular blog, we are getting the existing blog document, adding new comment (sub document) in front-end and again updating the blog document with blog ID.
If it is the case, let us take very popular blog scenario where thousands of comments were posted to a blog. If any new comment has to be posted, we need to get all the existing comments from DB server to Web server as a result it will increase network traffic.
Is this general scenario or is there any alternative way to add new content to sub document? Means, I need a functionality which should just insert new values in existing document.

推荐答案

这篇关于使用asp.net更新MongoDB中的子文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆