Call update function with POST/PUT body
Hello 1999,
Thanks for your work. It's very elegant and helpful.
I'm a little bit confuse about this problem:
couch.updateFunction("databaseName", "designDocument", "updateFunction", {optional query string}, "docid")
URL query parameters object. Note that multiple keys are not supported and the last key value suppresses others. From CouchDB document - Request Object
So does this means {optional query string} could have only one key-value pair? If there any plan to add method to submit POST/PU body with this function?
Thank you again.
Thank you for your kind words. This part is contributed by @bgardner87 so hopefully he knows more about this.
@winfredkqin It's been a while since I've looked at it, but it appears it's a limitation in the CouchDB api so there isn't much to be done here in this library. I think if you need to make use of multiple query parameters, you may have to use multiple requests but that may or may not work for your use case.
@bgardner87 Thanks for your reply.
When the request to an update handler includes a document ID in the URL, the server will provide the function with the most recent version of that document. You can provide any other values needed by the update handler function via the POST/PUT entity body or query string parameters of the request.
It seems CouchDB doc encourages developers to use POST/PUT body rather than query parameter. I think maybe pass JSON via HTTP body could be a better approach.
@winfredkqin I agree, the update function in this api could probably be updated to allow using post/put body as well as query string. It sounds like it would be a good add to me.