在密钥数组中使用startkey& endkey的CouchDB错误

时间:2016-07-08 09:50:56

标签: javascript view couchdb

大家好我试图使用以下请求:

  

curl http://localhost:5984/contacts/_design/country/_view/USA?startkey=[" USA",{}]& endkey = [" USA",{}]。

在以下视图中:

{
"_id": "_design/country",
"_rev": "1-51488ea3931fdca9b9e2de84ef99c4d9",
"language": "javascript",
"views": {
   "USA": {
       "map": "function(doc) {\nif(doc.type == \"contact\") \nemit([doc.country,doc.name] , {name: doc.name, email: doc.email});\n}\n"
   }
 }
 }

我得到了这个错误:第72列中的[globbing]坏范围

你能帮助我吗?

2 个答案:

答案 0 :(得分:1)

问题来自cUrl我想?试试这个:

-g/--globoff
              This  option  switches  off  the "URL globbing parser". When you set this option, you can
              specify URLs that contain the letters {}[] without having them being interpreted by  curl
              itself.  Note  that  these  letters  are not normal legal URL contents but they should be
              encoded according to the URI standard.

答案 1 :(得分:0)

只需编码括号,以便curl不会抱怨。 你可能想要使用不同的开始键(没有大括号),否则你不会得到任何结果。正确的一行:

curl http://localhost:5984/contacts/_design/country/_view/USA?startkey=%5B"USA"%5D&endkey=%5B"USA",%7B%7D%5D