根据这里的文件:https://wiki.apache.org/couchdb/Document_Update_Handlers#Request
我可以指定一个接受查询字符串参数的更新处理程序。例如。 (直接来自文档):
handlerName: function(doc, req) {
var field = req.query.field;
var value = req.query.value;
var message = 'set ' + field + ' to ' + value;
doc[field] = value;
return [doc, message];
}
然而,当我查看req对象时,没有query.value字段。我的cURL命令如下所示:
curl -X PUT http://127.0.0.1:5984/map_reduce2/_design/mp2/_update/test/1?field=THEFIELD&value=THEVALUE
结果文件如下:
{
"_id": "1",
"_rev": "24-06f05b375e4da9ec2fc88e28711fff7d",
"x": {
"info": {
"db_name": "map_reduce2",
"doc_count": 30,
"doc_del_count": 4,
"update_seq": 168,
"purge_seq": 0,
"compact_running": false,
"disk_size": 970856,
"data_size": 187724,
"instance_start_time": "1461749557106546",
"disk_format_version": 6,
"committed_update_seq": 168
},
"id": "1",
"uuid": "cb9251557f16b50c26ef2abd8200a727",
"method": "PUT",
"requested_path": [
"map_reduce2",
"_design",
"mp2",
"_update",
"test",
"1?field=THEFIELD"
],
"path": [
"map_reduce2",
"_design",
"mp2",
"_update",
"test",
"1"
],
"raw_path": "/map_reduce2/_design/mp2/_update/test/1?field=THEFIELD",
"query": {
"field": "THEFIELD"
},
"headers": {
"Accept": "*/*",
"Host": "127.0.0.1:5984",
"User-Agent": "curl/7.43.0"
},
"body": "undefined",
"peer": "127.0.0.1",
"form": {
},
"cookie": {
},
"userCtx": {
"db": "map_reduce2",
"name": null,
"roles": [
]
},
"secObj": {
}
}
}