views:

53

answers:

1

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).

  1. The blog was taken a main document
  2. Comments were taken as sub document and posted along with main document
  3. 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.

A: 

MongoDB supports a "push" command. The push command will append an item to an existing array.

Gates VP