从命令行使用 _find
Using _find from the command line
我的 CouchDB(1.7 版。1_5)设置:
$ curl -X PUT http://127.0.0.1:5984/shop
$ curl -d "{\"type\": \"product\", \"name\": \"Apple\", \"price\": \"1\"}" \
-X POST -H "Content-type: application/json" http://localhost:5984/shop/
{"ok":true,"id":"1ce330a867a803fd10082c451304075b",
"rev":"1-f61d5b64af58a6eda60ac0c9160ad690"}
现在我想查找名称为 Apple
的产品。根据 http://docs.couchdb.org/en/stable/api/database/find.html,我应该为此使用 _find
。但我找不到正确的语法。这个请求有什么问题?
$ curl -d "{\"selector\": {\"name\": \"Apple\"}}" \
-H "Content-Type: application/json" -X POST http://localhost:5984/shop/_find
{"error":"bad_request","reason":"Referer header required."}
您没有提到您的 CouchDB 版本。它是什么? CouchDB 1.6.1 不支持像 _find
API 这样的芒果查询。
Mango 查询服务器,一个在端点 /{db}/_find
后面,仅包含在从 version 2.0.0
开始的 CouchDB 中
我的 CouchDB(1.7 版。1_5)设置:
$ curl -X PUT http://127.0.0.1:5984/shop
$ curl -d "{\"type\": \"product\", \"name\": \"Apple\", \"price\": \"1\"}" \
-X POST -H "Content-type: application/json" http://localhost:5984/shop/
{"ok":true,"id":"1ce330a867a803fd10082c451304075b",
"rev":"1-f61d5b64af58a6eda60ac0c9160ad690"}
现在我想查找名称为 Apple
的产品。根据 http://docs.couchdb.org/en/stable/api/database/find.html,我应该为此使用 _find
。但我找不到正确的语法。这个请求有什么问题?
$ curl -d "{\"selector\": {\"name\": \"Apple\"}}" \
-H "Content-Type: application/json" -X POST http://localhost:5984/shop/_find
{"error":"bad_request","reason":"Referer header required."}
您没有提到您的 CouchDB 版本。它是什么? CouchDB 1.6.1 不支持像 _find
API 这样的芒果查询。
Mango 查询服务器,一个在端点 /{db}/_find
后面,仅包含在从 version 2.0.0