Couchdb 更新处理程序
以下:CouchDB 文档更新处理程序(就地更新) 和 < a href="http://wiki.apache.org/couchdb/Document_Update_Handlers" rel="nofollow noreferrer">http://wiki.apache.org/couchdb/Document_Update_Handlers
我正在尝试创建自己的函数,暂时增加一个整数,但我得到:
{"error": "bad_request","reason":"附件名称不能以 '_' 开头"}
我的设计文档如下所示:_design/db
"check": {
"increment": "function(doc,req){ var channel = req.query.channel; doc.channels[0].sp = doc.channels[0].sp+1; return[channel, 'check']}"
}
请求如下:
curl -X PUT https://server/db/_design/db/_check/increment/channels?channel=foo
我不太明白我的意思米做错了,如果我删除 '_',我会得到:
{"error":"conflict","reason":"文档更新冲突。"}
谢谢
Following: CouchDB Document Update Handlers (in-place updates) and http://wiki.apache.org/couchdb/Document_Update_Handlers
I'm trying to create my own function which increment an integer for now, but I'm getting:
{"error":"bad_request","reason":"Attachment name can't start with '_'"}
My design document looks like: _design/db
"check": {
"increment": "function(doc,req){ var channel = req.query.channel; doc.channels[0].sp = doc.channels[0].sp+1; return[channel, 'check']}"
}
And the request is like:
curl -X PUT https://server/db/_design/db/_check/increment/channels?channel=foo
I don't understand very well what I'm doing wrong, if I remove the '_' I will get:
{"error":"conflict","reason":"Document update conflict."}
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你的要求是错误的。尝试这样的操作:
其次,您的更新处理函数应该直接位于设计文档中的“更新”键中(因此不作为任何视图的一部分)。所以你的设计文档应该是这样的:
Your request is wrong, I think. Try something like this:
Second, your update handler function should be in an "updates" key directly in the design document (so not as part of any view). So your design document should look like this: