:clouchdb ID 错误
我在 :clouchdb
示例代码(这是一个链接,但其中包含的 examples.lisp
文件也无法正常工作)。
具体来说,当我输入时,
> (create-document '((:|name| . "wine") (:|tags| . ("beverage" "fun" "alcoholic"))))
我得到一个 DOC-ERROR
条件
Reason "Content-Type must be application/json", Document ID: "NIL"
[Condition of type DOC-ERROR]
Restarts:
0: [RETRY] Retry SLIME REPL evaluation request.
1: [*ABORT] Return to SLIME's top level.
2: [TERMINATE-THREAD] Terminate this thread (#<THREAD "repl-thread" RUNNING {10040D2E11}>)
Backtrace:
0: (POST-DOCUMENT ((:|name| . "wine") (:|tags| "beverage" "fun" "alcoholic")))
1: (SB-INT:SIMPLE-EVAL-IN-LEXENV (CREATE-DOCUMENT '((:|name| . "wine") (:|tags| "beverage" "fun" "alcoholic"))) #<NULL-LEXENV>)
--more--
该示例的预期效果是让 CouchDB 为新文档分配一个 ID(这在链接页面和注释中都已明确说明)的代码文件)。
我正在运行来自 Debian 存储库的 SBCL 1.0.40.0、clouchdb_0.0.11(直接来自 Quicklisp)和 CouchDB 0.11,以防万一。我也在 64 位 Debian 机器上。
有人能指出我正确的方向吗?
I'm getting an error on one part of the :clouchdb
example code (that's a link, but the examples.lisp
file included doesn't work properly either).
Specifically, when I input
> (create-document '((:|name| . "wine") (:|tags| . ("beverage" "fun" "alcoholic"))))
I get a DOC-ERROR
condition
Reason "Content-Type must be application/json", Document ID: "NIL"
[Condition of type DOC-ERROR]
Restarts:
0: [RETRY] Retry SLIME REPL evaluation request.
1: [*ABORT] Return to SLIME's top level.
2: [TERMINATE-THREAD] Terminate this thread (#<THREAD "repl-thread" RUNNING {10040D2E11}>)
Backtrace:
0: (POST-DOCUMENT ((:|name| . "wine") (:|tags| "beverage" "fun" "alcoholic")))
1: (SB-INT:SIMPLE-EVAL-IN-LEXENV (CREATE-DOCUMENT '((:|name| . "wine") (:|tags| "beverage" "fun" "alcoholic"))) #<NULL-LEXENV>)
--more--
The intended effect of the example is to have CouchDB assign an ID to the new document (this is made clear both in the linked page and in the comments of the code file).
I'm running SBCL 1.0.40.0, clouchdb_0.0.11 (straight out of quicklisp) and CouchDB 0.11 from the Debian repos, in case it matters. I'm also on a 64-bit Debian box.
Can anyone point me in the right direction?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
评论(2)
刚刚检查了来源。罗伯特·纽森(Robert Newson)上述是正确的; clouchdb
仍在将 content-type
设置为“text/javascript”,同时post
ing 和 put
ting 文档(无论如何,后者似乎都可以工作,只有帖子错误)。
如果您不想按照我上面的建议使用 chillax,您可以进入 clouchdb.lisp 文件并更改 post-document
的定义,使其设置 :content-type< /code> 到“application/json”。
然后,您应该能够在没有 :id
设置的情况下create-document
,CouchDB 将通过为您生成一个新文档来响应。
基于 clouchdb
的 quicklisp
代码的补丁(并不是说这复杂到需要一个):
--- clouchdb.lispOLD 2011-09-24 09:38:20.000000000 -0400
+++ clouchdb.lisp 2011-09-24 09:38:58.000000000 -0400
@@ -753,7 +753,7 @@
the :ID property."
(let ((res (ensure-db ()
(db-request (cat (url-encode (db-name *couchdb*)) "/")
- :content-type "text/javascript"
+ :content-type "application/json"
:external-format-out +utf-8+
:content-length nil
:method :post
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
CouchDB 在 POST 文档时需要“Content-Type: application/json”,这是一个相当新的要求,所以我认为 clouchdb 还没有这样做。
较短版本:听起来 clouchdb 与 CouchDB 的最新版本不兼容。
CouchDB requires a "Content-Type: application/json" when POST'ing documents, this is a fairly new requirement so I think clouchdb simply isn't doing it yet.
Shorter version: Sounds like clouchdb is not compatible with recent releases of CouchDB.