I know how to update a document in CouchDB, but when I update a doc, the fields that I didn't specify for the update gets deleted. How do I restrict the same. For instance, my CouchDB doc consists of fields: Name,Age,Email and I would like to update only the email field of this doc. So I just pass in the email field, it,s value, the doc id and its corresponding rev. But when I do such an update, my doc now will consist of only the E-mail. How do I restrict this., i.e, only the email id gets updated keeping the remaining fields and it's value intact.
I am using jquery.couch.js

2 Answers
2

Perhaps you are doing it all wrong... you are trying to solve the problem in CouchDB in non-CouchDB way. Why are you storing all the comments in one document? If you want to retrieve them in one request with the post, then you can use map to aggregate post and comments from separate documents like this:

So I just pass in the email field, it,s value, the doc id and its
corresponding rev.

You need to save the entire document with the updated values, not just the values you want to update. Think of the document itself as one big composite value; you can't change part of it without changing the entire thing.

So any suggestion on how to do it. I am creating a discussion board and saving my comments in the form of an array in the comments field. SO how do I achieve this so that when a user enters a comment it gets updated without affecting the previous comment.
–
swaroopsmAug 6 '12 at 12:51