Changing part of a document using CouchDB PUT
Reading the documentation (and playing around with the software), it looks like a PUT command will replace the entire existing document (create a new revision which includes only what was sent in PUT command). Is there a way to update part of a document?
For example, let's say a POST command creates a document with the following JSON object:
{"name" : "Chuck"}
Then a PUT command on the same document id adds:
{"lastname" : "Norris"}
Is there a way to get CouchDB to return the combination of the two revisions, as opposed to just the latest update? Otherwise any change to a开发者_如何转开发 document will require retrieving the complete document, and sending the complete (updated) document back.
Try looking into Document Update Handlers: when an update handler is PUT
from your application, the corresponding JavaScript function will be called with the data your application sent and the existing document on the server, which lets it merge the two pieces of data appropriately.
精彩评论