CouchDB URL rewrite: can I define a request body in the rewrite?
I want to create a rewrite handler that does a bulk insert e.g:
"from": "/createSomeStuff",
"to": "../../_bulk_docs",
"method": "POST"
this works fine ... but id also like the build the request body in the rewrite rules. Much akin to the way the query is built in this example I found on URL rewriting:
"rewrites": [
{
"from": "/blog",
"to": "_list/posts/all",
"query": {
"descending":true,
"limit": 5
}
}
],
is there any way to do somthing like this:
"from": "/createSomeStuff",
"to": "../../_bulk_docs",
"method": 开发者_如何学Python"POST",
"request" : {
"body":{{"foo": true},{"bar" : false}}
}
This is not possible as far as I know. However you are probably trying to set some default values. This can be done in another way. You have to create an update handler and append it to rewrite url. E.g. I have the following rewrite:
{ "from": "createSomeStuff",
"to" : "../your_design_doc/_update/in-place",
"method": "POST"
}
In your design doc you add something like described here CouchDb automatic timestamps
精彩评论